Add value 5 at the end of the list / tuple

0
lista_da_tupla_a=(["0", "33", "40"], ["8", "30","9"], ["7", "0", "0"])

lista_da_tupla_a = list

lista_da_tupla_a[2] = "5"

print(lista_da_tupla_a)

Desired output: (["0", "33","5"], ["8","30",5], ["7","0","5"])

    
asked by anonymous 21.07.2018 / 00:33

1 answer

0

I think what you want is this:

lista_da_tupla_a = (["0", "33", "40"], ["8", "30","9"], ["7", "0", "0"])
for tuplinha in lista_da_tupla_a:
    tuplinha[2] = "5"
print(lista_da_tupla_a)

That is, you use for to go through each trio and replace the third element with "5" .

Here's the output:

(['0', '33', '5'], ['8', '30', '5'], ['7', '0', '5'])

See here working on ideone.

    
21.07.2018 / 01:15