+ 1
Beginner Python question.
Hi guys, I'm halfway through my python course and was trying to write a program. I wanted to ask if you can edit items in a list like this. Thanks in advance. https://code.sololearn.com/ckOgxAWh3HLA/?ref=app
5 Answers
+ 2
See this Code..
If you have any doubts..
Ask me..
Thank You..!!
https://code.sololearn.com/chU5vlv3aeix/?ref=app
+ 2
There are a few ways that you edit a list. It won't work the way that you have it however, since x would be a local variable.
But traversing over the index of the list will work.
asdf=[0]*10
for i in range(len(asdf)):
asdf[i]=input("Number")
print(asdf)
+ 2
No, you can't. X is just a variable that holds the current iteration value. When you change it you change the current value of x but not the list slot.
This works:
for x in range(len(myList)):
myList[x]=input("Number")
+ 2
Thank you very much ChaoticDawg and Kevin Star
0
Eswar V No, I was trying to input 10 different numbers and see if it was possible to store them this way. Thank you for replying though.