logo
  • Python
  • Django
  • Tools
    • Email Extractor Tool Free Online
    • Calculate Text Read Time Online
    • HTML to Markdown Converter Online
    • Other Tools
  • About
  • Contact

Last modified: Jan 10, 2023 By Alexander Williams

How to return tuple in python with example

example


def animals():
    #tuple
    animals = ('cat', 'dog', 'zebra', 'shark')
    
    #return
    return animals


#call and print function
print(animals())

output

#('cat', 'dog', 'zebra', 'shark')

loop over tuple


animals = animals()

for animal in animals:
    print(animal)

output

cat                                                                                                                                   
dog                                                                                                                                   
zebra                                                                                                                                 
shark

Recent Tutorials:

  • Creating an Image Cartoonizer with Flask - Complete with Source Code
  • How to use render_template in Flask
  • Convert Image to Text with Flask (Source Code)
  • Understand How to Work with Table in beautifulsoup
  • Estimating Reading Time of Text and Text File using Python
  • Beautifulsoup Get all Links
  • How to Use BeautifulSoup To Extract Title Tag
  • Convert Your Django Project to a Static Site and Host it for Free

Related Tutorials:

  • Estimating Reading Time of Text and Text File using Python
  • 3 Easy Methods for Capitalizing Last Letter in String in Python
  • How To Solve no module named datasets
  • Python Get Root and Sub Domain From URL
  • Python-pycountry | Understand How to Use pycountry
  • Python: Get First, Second, Last word in String
  • Python Check if String is Datetime
  • Remove HTTPS or HTTP From URL Python
  • Facebook
  • Twitter
  • Youtube

Copyright PyTutorial Blog Co.