Reputation: 111
records = [["chi", 20.0],["beta", 50.0],["alpha", 50.0]]
a = len(records)
for i in range(3):
var = records[i]
print(var)
What I want to do is to create a different variable for each list (for instance there are three lists in records so i want to assign each list to a different variable (3 variables since there are three lists)). However, it only prints the last list(["alpha", 50.0]) and only one variable is assigned (var).
Upvotes: 0
Views: 1205
Reputation: 136
because var is not appending anything it's just overwriting the value in Var but there isn't much point in appending it to separate lists as its all in one list already and everything is accessible by using
records[X][Y]
with X being the sublist location and Y being the value inside that sublist
and if you want this to be easier to use i'll suggest using dictionaries but this isn't necessary
Upvotes: 2