How to return tuple in python with example
- Last modified: 30 March 2020
- Category: python tutorial
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
English today is not an art to be mastered it's just a tool to use to get a result