+ 2
Can A Function return Multiple Values ??
Justify by giving an example please
9 Respuestas
+ 10
You could use generator functions to yield different values each time it gets called (python)
+ 6
I'd say it can't. It can return a list or a tuple with multiple values. Technically, that's pretty much the same as returning a string (which is an array of chars) and I don't think anyone would define that as "returning multiple values"
+ 5
I'm not a Python expert so won't give an example but in other languages a collection or an object can be returned which contains multiple values. Multiple values can also be returned via pass by reference parameters. I will let a python programmer give you language specific examples.
+ 5
According to this link, there are several ways to return multiple values from a function.
https://www-geeksforgeeks-org.cdn.ampproject.org/v/s/www.geeksforgeeks.org/g-fact-41-multiple-return-values-in-JUMP_LINK__&&__python__&&__JUMP_LINK/amp/?amp_js_v=a2&_gsa=1&usqp=mq331AQCCAE%3D#referrer=https%3A%2F%2Fwww.google.com&_tf=From%20%251%24s&share=https%3A%2F%2Fwww.geeksforgeeks.org%2Fg-fact-41-multiple-return-values-in-python%2F
+ 4
Yes, it can.
def foo():
return 1, 2
a, b = foo()
#a = 1 and b = 2
+ 4
If you return a list you can split it to return multiple values .... RETURN KEYWORD can be used only ONCE 🤔
+ 1
Yes, it returns a list, and then we do unpacking.
0
https://code.sololearn.com/c80xZ9OOz6c3/?ref=app
So what do I need to do to this to improve it. It treats each character in the list as a value instead of the values itself like you would expect. I made it work with 1 digit numbers, but I plan to do more
0
Nvm, I got it