Lista rozpakowań Python
# unpack a list python:
list = ['red', 'blue', 'green']
# option 1
red, blue = colors
# option 2
*list
Repulsive Raven
# unpack a list python:
list = ['red', 'blue', 'green']
# option 1
red, blue = colors
# option 2
*list
def print_items(item1, item2, item3, item4, item5, item6):
print(item1, item2, item3, item4, item5, item6)
fruit = ["apple", "banana", "orange", "pineapple", "watermelon", "kiwi"]
# deconstructs/unpacks the "fruit" list into individual values
my_function(*fruit)
elems = [1, 2, 3, 4]
a, b, c, d = elems
print(a, b, c, d)
# 1 2 3 4
# or
a, *new_elems, d = elems
print(a)
print(new_elems)
print(d)
# 1
# [2, 3]
# 4