Why would you use the return statement in Python? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why would you use the return statement in Python?

what will happen if we don't use return in function definations

13th Jan 2017, 6:45 AM
Gopikrishna A
Gopikrishna A - avatar
1 Answer
+ 1
even if not programmed your function will return None. That is ok, but good style is to return smthng like "done", True, "OK" or any other. It will really helpful during debug. With return you can easily check if func did everything right (if myfunc() == True), without it you should check function work totally manually.
18th Jan 2017, 7:38 PM
Алексей БутылкУс
Алексей БутылкУс - avatar