There are several issues in your original code:
sequences = ["A","B","A","A","B"]
lista = sequences
lista.pop(0)
print(lista)
for x in range(sequences):
mc =sequences[x]+lista[x]
Firstly, the statement lista = sequences does not make a copy of sequences. Instead, lista and sequences become two different names for the same list. What you do using one name also happens to the other. lista.pop(0) is the same as sequences.pop(0). If you want a copy, then import the copy library.
import copy
sequences = ["A","B","A","A","B"]
lista = copy.copy(sequences)
lista.pop(0)
print(lista)
for x in range(sequences):
mc =sequences[x]+lista[x]
Secondly, your statement range(sequences) is incorrect. The range() function accepts integers as input, not lists. That's what gave you TypeError: 'list' object cannot be interpreted as an integer
# VALID
range(5)
range(3)
range(10)
# INVALID
range(["A","B","A"])
range(["eyes", "nose", "tail"])
sequences is a list. You want range(len(sequences)) notrange(sequences)
In the end, we can modify your original code to work:
import copy
sequences = ["A","B","A","A","B"]
lista = copy.copy(sequences)
lista.pop(0)
print(lista) # prints ["B","A","A","B"]
mc = list()
for x in range(len(lista)):
mc.append(lista[x] + sequences[x + 1])