+ 2
Changing an item in a list using a for loop
for x in some_list: if x == 0: change x to something
5 ответов
+ 4
Hi David Gedalia Ordman
Could you please state your question.
Having trouble? Read this:
https://www.sololearn.com/discuss/1316935/?ref=app
+ 1
David Gedalia Ordman , do you know how get a value from list?
lets say.. how do i print 5 from list = [1,2,2,4,5,6,3,8] ?
0
@Qwertiony
print (list[4])
0
David Gedalia Ordman , Pro!!!
Now, with this knowledge, how can you make this 5 become 9?
in a way that print(list[4]) will outout 9.
0
you should just write
list[4] = 9
and if you use print ( list ) you’ll see the difference