# 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)
function_that_needs_strings(*my_list) # works!
l = [0, 1, 2]
a, b, c = l
print(a)
print(b)
print(c)
# 0
# 1
# 2
x,y,z = [5,10,15]
print(x)
print(y)
print(z)
def fun(a, b, c, d):
print(a, b, c, d)
# Driver Code
my_list = [1, 2, 3, 4]
# Unpacking list into four arguments
fun(*my_list)
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