我想在用户作为输入给出的选择与选择存储为变量之间循环
filenames = ['file1.txt', 'file2.txt']
for filename in filenames:
# ... see code above
答案 0 :(得分:0)
您可以在while True
循环内请求输入,然后在给出有效输入后从其中break
退出输入:
action_map = {
"A": str(Ac),
"S": str(Sc),
"D": str(Dc),
"F": str(Fc)
}
while True:
action_input = input("\n ")
action_input1 = action_input.title()
if action_input1 in action_map:
print("\n Required Result is : " + action_map[action_input1])
break
else :
print("\n Please enter from the choices given above")