You are viewing a single comment's thread from:

RE: Python practice tests

in #coding7 years ago

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

Sort:  

That depends on the indentation:-)

The indentation went wrong because of improper markdown

Coin Marketplace

STEEM 0.05
TRX 0.33
JST 0.080
BTC 63745.71
ETH 1690.28
USDT 1.00
SBD 0.41