Reputation: 11
Hi I'm trying to make a function to print a range of numbers. the "A" code runs correctly but the "b" code only prints "50"
for i in range (50,110,10):
print(i)
def rest(rmin,rmax,intervals):
for i in range(rmin,rmax,intervals):
return i
print(rest(50,110,10))
Upvotes: 1
Views: 50
Reputation: 21991
Please see the following code for accomplishing what you are trying to do:
>>> for integer in range(50, 110, 10):
print(integer)
50
60
70
80
90
100
>>> def rest(minimum, maximum, interval):
for integer in range(minimum, maximum, interval):
yield integer
>>> print(*rest(50, 110, 10), sep='\n')
50
60
70
80
90
100
>>>
Upvotes: 1