Checkpoint 11.13.1.
Write a function called
tup_creation
that takes in two integer parameter, start
and end
, and returns a tuple with all the values between start
(inclusive) and end
(non-inclusive). For example, tup_creation(-8,3)
would return (-8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2)
and tup_creation(10,3)
would return (10, 9, 8, 7, 6, 5, 4)
.
Solution.
Write a function called tup_creation that takes in two integer parameter, start and end, and returns a tuple with all the values between start (inclusive) and end (non-inclusive). For example, tup_creation(-8,3) would return (-8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2) and tup_creation(10,3) would return (10, 9, 8, 7, 6, 5, 4).
def tup_creation(start, end):
lst = []
if start > end:
for i in range(start,end,-1):
lst.append(i)
else:
for i in range(start,end):
lst.append(i)
lst = tuple(lst)
return lst