Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

How can we return a tuple from a Python function?

I have a tuple given below

('tutorialspoint', 30)

How do I return this tuple or any given tuple from a python function?


1 Answer
Manogna

We can return a tuple from a python function in many ways. For the given tuple, we define a  function as shown below.

def foo():
    str = "tutorialspoint"
    x   = 30
    return (str, x);            
print foo()

OUTPUT

('tutorialspoint', 30)
Advertisements

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.