I want to make changes to a list in-place such that if the list is l1 = [0, 1, A, B]
, then I can replace the alphabetical values with numbers.
I tried using the following code for it:
for x in l1:
if x == 'A':
x = 10
However, when I look at the list again, it is still the same and A has not been changed to 10. Why is this code not working?
I tried using the indices instead as well, but that did not work either.
for i in range(len(l1)):
if l1[i] == 'A':
l1[i] = 10