0
How can I change a number in list? (Python)
I tried it with enumerate but it does not work. list = [30, 20, 10] for n, i in enumerate(list): if i == 20: list[n] = 25
4 Answers
+ 3
The problem is not enumerate but list.
You overwrite the built-in type list by calling your list like that.
Name it list_ and your code works.
About your naming: The index should be i and the number n.
+ 3
add a print(list) at the end out side of the loop and you see that your code did work
+ 2
Okay. Thank you.
0
Yea.. right with print(list) ... đ