def func(a,b,c):
for x,y,z in a,b,c:
pass
func(((1,2),(1,3)),((1,4),(1,5)),(1,2))
I expect x,y,z
to get the values (1,2)
, (1,4)
, and 1
. Instead I'm getting an error:
ValueError: not enough values to unpack (expected 3, got 2)
You need to zip the lists in order to do a for-loop like that without iterating through the arguments passed into func()
:
def func(a,b,c):
for x,y,z in zip(a,b,c):
pass
func(((1,2),(1,3)),((1,4),(1,5)),(1,2))
Otherwise, the for-loop will iterate through every argument passed into func
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With