+ 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

1st Sep 2018, 11:47 PM
Ethan Hodge-Tonkin
Ethan Hodge-Tonkin - avatar
2 Answers
+ 2
If i understood you. user = input() lst = [] try: lst[lst.index(user)] = "username" except: print("name doesn't exist")
2nd Sep 2018, 12:06 AM
Toni Isotalo
Toni Isotalo - avatar
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
2nd Sep 2018, 12:36 AM
Mike Utty
Mike Utty - avatar