Multiple Return Statements in a Python Function #Shorts

preview_player
Показать описание
Multiple Return Statement in a Python Function #Shorts

Did you know a function can contain more than one return statement? There are multiple ways to handle such a situation. Check out the shorts to know how to do it.

If you want to learn more hacks on programming, subscribe now. Also, do turn on your notifications so that you will be notified whenever we post new videos.

PS. Follow us elsewhere for more amazing content:

#shorts #programiz #programmingtricks #pythonifelse #learnprogramming #learntocode
Рекомендации по теме
Комментарии
Автор

This is just a simple shorthand if-else statement bro.

Multiple return is a keyword called Yield.

limjetin
Автор

you can return multiple variables too, for example `return 1, False, "Food"` and you would call this like this
`int_var, bool_var, str_var = function()`

djdoggo
Автор

Could you not just use a ternary statement like in C#?
E.G.
return age >= 18 ? “Yes” : “No”

scottwalker
Автор

Harder tips please. This is general knowledge

FADHsquared
Автор

God, Python is confusing. I don't get how people can actually write software in it.

davydorynbaev
Автор

Bad practice. A function should have only one exit statement.

ENTERGOIL