Skip to content
Advertisement

python starred expression assigned to multiple variables [closed]

I have this starred expression but it gives error SyntaxError: can't use starred expression here so any alternative solutions would be appreciated.

def checker(packages):
    for pac in packages:
        print(*pac)
        a,b,c=*pac
        return a,b,c
print(checker([[4,3,7],[9,6,1]]))

Advertisement

Answer

Just remove the * :

a, b, c = pac

This is enough for python to unpack right hand side of the assignment.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement