0

return keyword

Why there is a difference between the two ''return''? def hello1(): for i in range(5): print("Hello world!") print (i) return hello1 () def hello2(): for i in range(5): print("Hello world!") print (i) return hello2 ()

20th Oct 2018, 7:50 AM
Rich
3 Réponses
+ 4
One is in the loop and the other in the function body which obviously gives different results as the return in the loop exits the loop and function prematurely.
20th Oct 2018, 7:57 AM
TurtleShell
TurtleShell - avatar
0
because python uses indentation to structure code.
20th Oct 2018, 1:34 PM
Bebida Roja
Bebida Roja - avatar
0
Why there is just one ''0'' for the top code?
20th Oct 2018, 11:05 PM
Rich