drinksList = ["Fanta", "CocaCoal", "7up"]
userDrink = input("What soft drink are you looking for?")
if userDrink in drinksList:
print(userDrink,"is in stock!")
elif userDrink not in drinksList:
print("Sorry,", userDrink,"is currently not is stock.")
From here I would like to ask the user whether or not they would like to order the named soda in. If they answer yes I want to append or insert their named soda into my list.
order = input("Would you like us to order some for you?")
if order == "yes" or order == "Yes":
drinksList.append("userDrink")
print("Ok, we have added", userDrink,"to our stock!")
print(drinksList)
I would also want the code to end if the user does not want to order their drink. But at the end display the message "Thank-you for coming!". I only want this message to appear through this path and not at the end of the code, which keeps happening.
else:
print("Ok, thank-you for coming!")
print("Ok, we have added", userDrink," to our stock!")
Here it does not print what the user has inputted but instead prints the word userDrink.
不完全确定你想要什么,但可能是这样的:
相关问题 更多 >
编程相关推荐