zazuvahe
zazuvahe

Reputation: 33

Possible unbalanced tuple when declaring multiple array

So I want to declare multiple array in 1 line but when I do that I get this warning "Possible unbalanced tuple"

I know it can be ignored but what is wrong? why when I declare these in separate line its OK but in 1 line I get this error?

#get error:
arrayOne,arrayTwo = []
#not getting error: why?
arrayOne = []
arrayTwo = []

Thanks

Upvotes: 0

Views: 35

Answers (1)

chepner
chepner

Reputation: 532538

You aren't assigning [] to both names; you are trying to unpack exactly two items from [] and assign each one to a separate name. You can write

listOne, listTwo = [], []

but this is more clearly written as two lines

listOne = []
listTwo = []

Upvotes: 2

Related Questions