I have a list ['1', '2', '3', '4']
and I want to convert it to the following: ['1.0', '2.0', '3.0', '4.0'].
In the code below, why does the second attempt work and not the first?
>>> list = ['1', '2', '3', '4']
>>> for element in list:
... element = element + '.0'
...
>>> print(list)
['1', '2', '3', '4']
>>> for element in range(len(list)):
... list[element] = list[element] + '.0'
...
>>> print(list)
['1.0', '2.0', '3.0', '4.0']
listas variable name.elementnot eachlist element