Can a function in Python return multiple values? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can a function in Python return multiple values?

Generally, a function can return only 1 value in the form of either sequence or data type but is there any different theory regarding returning a tuple in terms of returning multiple values from a function?

28th Feb 2020, 12:42 PM
AMISHA NARSINGANI
AMISHA NARSINGANI - avatar
5 Answers
+ 5
Hello, no it is not possible. Only 1 value. So you must rely on tuples etc.
28th Feb 2020, 12:46 PM
Oma Falk
Oma Falk - avatar
+ 4
~ swim ~ cool but under the hood it is a tuple too
28th Feb 2020, 12:47 PM
Oma Falk
Oma Falk - avatar
+ 1
Yeild generator does help you return every iteration value from loop in a function..
28th Feb 2020, 12:45 PM
Jayakrishna 🇮🇳
0
~ swim ~ can u explain with an example?
2nd Mar 2020, 7:07 AM
AMISHA NARSINGANI
AMISHA NARSINGANI - avatar
0
In terms of tuple
2nd Mar 2020, 8:49 AM
AMISHA NARSINGANI
AMISHA NARSINGANI - avatar