Hi folks,
I am new to python and would appreciate a little help.
How does one do the following:
Having converted each line within a file to a nested list, e.g.
[['line 1', 'a'], ['line 2','b']]
how do I flatten the list so that each line is associated with a variable. Assume that the first member in each list, i.e.i[:][0]
, is known.Is it possible to associate more than one list with one variable, i.e. can
x = [list1], [list2]
?Having used a for loop on a list, how those one associate aspects of that list with a variable? See example below.
Example:
for i in list_1:
if i[:][0] == 'm':
i[2] = a
i[3] = b
i[4] = c
The above returns NameError, a, b, c, not defined. How does one define variables resulting from iterations in a for loop or loops in general?
Hope I was clear and succinct as I am perplexed!
Thanks in advance, Seafoid.