小编Mat*_*tjo的帖子

Adding strings in lists together

I want to transform the list ["A","B","A","A","B"] to the list ["AB","BA","AA","AB"].

I have tried to define a new list in which the first element is deleted and then add the strings of the lists together. After which I plan to delete the last element of the new list to get the result.

lista = sequences
lista.pop(0)
print(lista)

for x in range(sequences):
    mc =sequences[x]+lista[x]
Run Code Online (Sandbox Code Playgroud)

But all I get is

TypeError: 'list' object cannot be interpreted as an integer

Any help …

python string list

12
推荐指数
3
解决办法
869
查看次数

标签 统计

list ×1

python ×1

string ×1