我正在编写一个程序,该程序具有多个选项来修改python中的字典。用户有四个选项,完成一个选项后,我希望程序将用户带回主菜单。到目前为止,每个选项都可以正常工作,只是它不会使用户回到主菜单,而是永远循环。
user_input = int(input("Faites un choix...")) liste_epicerie = {} while True: if user_input == 1: print(liste_epicerie) if liste_epicerie == {}: print("La liste est vide") continue
因此,此代码应将用户带回user_input,但始终打印“ La liste est vide”。我在做什么错?
我正在编写一个程序,该程序具有多个选项来修改python中的字典。用户有四个选项,完成一个选项后,我希望程序将用户带回主菜单。 ...
您必须再次实际读取用户输入(在循环内:)>
liste_epicerie = {}
while True:
user_input = int(input("Faites un choix..."))
if user_input == 1:
# ...
elif ...:
# ...
# under some condition
break