Reputation: 2786
I have dynamic zip()
function call:
zip(id, value[0], value[1], value[2], value[3], value[4])
Value has a dynamic length: it could contain 3 or 4 or 7 elements, etc.
Is there a way I can make the zip()
function dynamic and work with a variable number of elements from value
?
e.g. pseudo code:
zip(id, for i in range(0,len(value)): value[i])
Upvotes: 1
Views: 2836
Reputation: 1122242
Use the *args
call syntax:
zip(id, *value)
Prepending value
with *
tells Python to apply each entry in value
as a separate argument to zip()
.
Upvotes: 7