My team and I have created a prototype function in Python where it would remove an item from a list.
Supposedly if the user typed in the same item they had deleted into the new updated list, and the expected output is that it would return the message "Item does not exist. Please choose an item from the list". I could also say the same, that if I wanted to delete an item that does not exist after the first time I had deleted an item, the expected output would be the message aforementioned.
Thereby, I suspect that something is wrong with the coding, but I do not know where.
menu = ["exp1","exp2","exp3","exp4","exp5"]
userInput = 0
try:
userInput = input("Enter item menu name that you want to remove >>")
except ValueError:
print("Item does not exists")
if userInput in menu:
print("The item is in the list")
else:
print("The item is not in the list. Please choose a different item.")
while userInput != "Stop" or userInput != "stop":
userInput = input("Do you want to remove an item from the menu? If so please type appropriate item menu name. If no please type Stop. >>")
if userInput == "Stop" or userInput == "stop":
print("The program has ended no more items will be removed.")
print(f"Current menu items: {menu}")
else:
menu.remove(userInput)
print(f"Current menu item list: {menu}")
We had tried to use if/else statements, try/except statements but so far without the expected output.