RE: RE: Python practice tests
You are viewing a single comment's thread from:

RE: Python practice tests

filler(58)
Published in
#coding
Words
81
Reading
1 min
Listen
Play
7y

return is a construction used in the code block of a function definition + after the return instruction is inserted the code block will stop executing anything so :

def print_nums(x):
for i in range(x):
print(i)
return
print_nums(10)

Program takes 0, verifies that is in range of 10 and prints 0
Because of the return statement program stops executing the code

If return is deleted from code the output will be
0
1
2
3
4
5
6
7
8
9

@filler: return is a | Ecency