Python Return Tuple from Function - Python Examples
pythonexamples.org › python-return-tupleIn this example, we shall return multiple tuples from the function using generators. Python Program. def myFunction(rollnos, names): #create tuple yield (rollnos[0], names[0]) yield (rollnos[1], names[1]) tuple1, tuple2 = myFunction([1, 2], ['Mike', 'Ram']) print(tuple1) print(tuple2) Run. Output (1, 'Mike') (2, 'Ram') Summary. In this tutorial of Python Examples, we learned how to return Tuple from a function, with the help of well detailed example programs.
Python Return Tuple From Function – PythonTect
pythontect.com › python-return-tuple-from-functionJan 22, 2022 · Another way to return a tuple from a function is by creating a tuple variable or object before returning it with the return statement. def myfun(): t = ("ismail","baydan",35) return t myt = myfun() print(myt) Assign Returned Tuple To Multiple Variables. Another powerful feature of returning a tuple from a function is the ability to assign every tuple item into a separate variable.