I have a list of lists that looks like this mylst
[[('Salmon', 9), ('Fish&Chips', 3), ('Pasta', 8), ('Shrimp', 10)],
[('Shrimp', 8), ('Fish&Chips', 10), ('Salmon', 9), ('Pasta', 7)],
[('Shrimp', 10), ('Fish&Chips', 6), ('Salmon', 8), ('Pasta', 5)],
[('Shrimp', 7), ('Pasta', 9), ('Salmon', 8), ('Fish&Chips', 8)],
[('Fish&Chips', 10), ('Shrimp', 8), ('Salmon', 9), ('Pasta', 3)]]
I can access the sublists if I print the desired index
mylst[0]
which returns
[('Salmon', 9), ('Fish&Chips', 3), ('Pasta', 8), ('Shrimp', 10)]
But I would like to store each sublist in a new list.
Because eventually I would like to extract the items(tuple index 0) and the quantity ordered (tuple index 1) for each sublist and store them in two separate lists. But I can't do this if I can't split the lists
I tried to iterate through the main list
newlst=[]
for sublst in mylst:
newlst.append(sublst)
and
newlst=[]
for i in range(len(mylst)):
for sublst in mylst:
newlst.append(mylst[i])
I am not sure how to split then store multiple outputs from each iteration of the for loop.
The desired output is to have the 5 sublists as seperate lists. For example
lst1=[('Salmon', 9), ('Fish&Chips', 3), ('Pasta', 8), ('Shrimp', 10)]
lst2 = [('Shrimp', 8), ('Fish&Chips', 10), ('Salmon', 9), ('Pasta', 7)]
and so on.
note: my question is not duplicate of this one, as I have read the solutions. I want to store my sublists in seperate lists. which is different.