mercredi 26 mars 2014

Iterate over List of Tuples Containing Lists


Vote count:

0




I have a quick question and I have been having trouble finding an answer to this exact question, though I'm sure it exists on the web somewhere! I am trying to iterate over a list of tuples in this form:



exList=[(a, [1,2,3]), (b, [1,2,3])]


I chose a list of tuples in order to easily iterate through the list, however I am running into python errors in regards to unpacking the elements. Using this kind of code:



for (elem1, elem2) in exList:
...Do something


I think I am providing enough places for the values to be unpacked, since elem2 could be a list. I'm not sure exactly what is going wrong, any advice would be appreciated!



asked 1 min ago






Aucun commentaire:

Enregistrer un commentaire