Question: In python can anyone help me to implement function using rang-based-for-loops def revrange(a,b): Returns the tuple (b-1, b-2, ..., a) Note that this tuple

In python can anyone help me to implement function using rang-based-for-loops def revrange(a,b): """ Returns the tuple (b-1, b-2, ..., a) Note that this tuple is the reverse of tuple(range(a,b)) Parameter a: the "start" of the range Precondition: a is an int <= b Parameter b: the "end" of the range Precondition: b is an int >= a """

#I have this rn

reverse = 0

for x in range(a,b):

if a <= b and b >= a:

reverse = range(a,b)

tups = tuple(reverse)

print(tups)

tups1 = list(tups)

tups3 = sorted(tups1, reverse = True)

print(tups3) tups = tuple(tups3)

return tups

#but getting this error

The call revrange(3) crashed. Traceback (most recent call last): UnboundLocalError: local variable 'tups' referenced before assignment

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!