TypeError: list indices must be integers or slices, not str
ruchiyadav (0)

PartyName=[]
while True:
print("""what you wish to do:
1.Insert party name
2.Update party name
3.Delete party name
4.View all party name
5.Exit""")
choice= int(input("Enter your choice:"))
if choice==1:
val= input("Enter party name")
key= input("Enter party abbriviation")
PartyName[key]= val
elif choice==2:
key= input("Enter Party abbriviation that you wish to change")
if PartyName.get(key) is None:
Print("Wrong Input")
else:
val= input("Enter party name")
key= input("Enter party abbriviation")
elif choice==3:
key= input("Enter Party abbriviation that you wish to delete")
if PartyName.get(key) is None:
Print("Wrong Input")
else:
PartyName.pop(key)
elif choice==4:
for key, val in PartyName.items():
print(key+'-'+val)
elif choice==5:
break

You are viewing a single comment. View All
Answered by Geocube101 (308) [earned 5 cycles]
View Answer
ruchiyadav (0)

@Geocube101 hi, thank you but using int also not fixing the problem.