Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

packing and unpacking in python

>>> def powers(number):
...     return number, number ** 2, number ** 3
...
>>> # Packing returned values in a tuple
>>> result = powers(2)
>>> result
(2, 4, 8)
>>> # Unpacking returned values to multiple variables
>>> number, square, cube = powers(2)
Source by stackabuse.com #
 
PREVIOUS NEXT
Tagged: #packing #unpacking #python
ADD COMMENT
Topic
Name
4+5 =