我正在尝试创建一个程序,如果用户想要将名称添加到列表中,它将询问一个问题,从列表中编辑名称删除名称或显示列表。我得到了一点,我在请求完成后重新出现问题时遇到问题。因此,在按下“1”并完成操作后,我想再次提问,直到用户退出程序。
这就是我所拥有的
#Creating a Searching?
names = []
answer = input("Create An Entry [Press 1] \nDisplay List [Press 2] \nEdit an Entry [Press 3] \nRemove Entry [Press 4] \nQuit [Press 5]")
# IF creating
if answer == "1" :
# collect information
firstname = input("What is the persons first name? ")
#add data
names.append(firstname)
answer = input("Create An Entry [Press 1] \nDisplay List [Press 2] \nEdit an Entry [Press 3] \nRemove Entry [Press 4] \nQuit [Press 5]")
# Display Data
elif answer == "2" :
print(names)
answer = input("Create An Entry [Press 1] \nDisplay List [Press 2] \nEdit an Entry [Press 3] \nRemove Entry [Press 4] \nQuit [Press 5]")
# USER Quit
elif answer == "5":
exit()