0
I need to fill out a list (without using packages like numpy or pandas) that has a format similar to the following:
lista1 = [0, 3, 7, 10, 15]
The numbers are increasing but do not follow an order or pattern. The fill I need to do cannot be with a number, but with some identifier (a generic string like 'falha'
or 'nan'
, for example). This must be done based also on the size of another list with a size n
. Let’s say the size of that list was i = 20
(It has an increasing size with step 1):
lista2 = [0, 1, 2, 3, 4, 5, 6, 7,..., 15, 16, 17, 18, 19, 20].
The output of the program would be something like:
0, 0
1, falha
2, falha
3, 3
4, falha
5, falha
6, falha
7, 7
...
15, 15
16, falha
17, falha
18, falha
19, falha
20, falha
The filling I even managed to do in a certain way using a insert
, but I get an error related to the size of the lists due to the difference at the end between the two.
Follow what I got:
listaf = []
for i in range(len(lista2)):
if lista2[i] == lista1[i]:
valorf = lista1[i]
listaf.append(valorf)
else:
valorf = lista1.insert(i, 'falha')
listaf.append(valorf)
If anyone can help I thank you. Thank you.