Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

tuples in python

#tuple unpacking
myTuple = ("Tim","9","Smith")
#tuple unpacking allows us to store each tuple element in a variable
#syntax - vars = tuple
"""NOTE: no of vars must equal no of elements in tuple"""
name,age,sirname = myTuple
print(name)
print(age)
print(sirname)
#extra
#this alows us to easily switch values of variables
name,sirname = sirname,name
print(name)
print(sirname)
Source by codefreelance.net #
 
PREVIOUS NEXT
Tagged: #tuples #python
ADD COMMENT
Topic
Name
1+3 =