Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

unpacking in python

#When we create a tuple, we normally assign values to it. 
#This is called "packing" a tuple:

#Packing a tuple:
fruits = ("apple", "banana", "cherry")

#But, in Python, we are also allowed to extract the values back into variables.
#This is called "unpacking":

#Unpacking a tuple:
fruits = ("apple", "banana", "cherry")

(green, yellow, red) = fruits

print(green)
print(yellow)
print(red)
Source by builtin.com #
 
PREVIOUS NEXT
Tagged: #unpacking #python
ADD COMMENT
Topic
Name
1+8 =