4
I have the following list:
pessoa=("Filipe", 40, True)
I write the print command for each element:
print(pessoa[0])
print(pessoa[1])
print(pessoa[2])
the answers are:
Filipe
40
True
When I try to modify the first element:
pessoa[0]="Marconi"
recebo a resposta de erro abaixo:
Traceback (most recent call last):
File "D:/Licença/Scripts/A5825_Listas.py", line 16, in <module>
pessoa[0]="Marconi"
TypeError: 'tuple' object does not support item assignment
How do I modify an element from a Python list?
AP clearly asked "list" - so he’s confusing lists and tuples - I think a legal answer should address that and explain the difference.
– jsbueno