Reputation: 65
Dears,
How can I keep the values from a for loop into a list.
lista = list([])
for x in datos[2572:2582]:
if re.match('\d{3}-(.*?)Todas', (x[0])):
lista = (x[0] + " FALSE")
elif re.match('\d{3}-', (x[0])):
lista = (x[0] + " TRUE")
else:
lista = (x[0] + " FALSE")
I would like to get a list 'lista' with the values upcoming from the previous code.
Upvotes: 0
Views: 189
Reputation: 7795
append()
adds elements to a list. For example, lista.append(x[0] + " FALSE")
Upvotes: 1
Reputation: 431
Though the question is not very clear, I assume this might be what you are looking for.
lista=[]
for x in datos[2572:2582]:
if re.match('\d{3}-(.*?)Todas', (x[0])):
lista.append(x[0] + " FALSE")
elif re.match('\d{3}-', (x[0])):
lista.append(x[0] + " TRUE")
else:
lista.append(x[0] + " FALSE")
Upvotes: 2