+ 1
Trying to find and update an item in a list
hi there im currently studying python at university and have been trying to complete an exercise for days. All I am looking to do is ask a user to input a username that is already placed inside a list, then change that username and update it on the list. any help anyone could give me with this would be much appreciated
2 Respostas
+ 2
If i understood you.
user = input()
lst = []
try:
lst[lst.index(user)] = "username"
except:
print("name doesn't exist")
0
Sorry for reposting. I meant to edit. I made it retain its index. Also I am new and teaching myself so this could be refined i am sure.
https://code.sololearn.com/cpz4D9Zitt67/?ref=app