Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Temple Of Django Database Performance

Authors: Andrew Brookins

1st Edition

1734303700, 978-1734303704

More Books

Students also viewed these Databases questions

Question

2. (1 point) Given AABC, tan A b b

Answered: 1 week ago