【发布时间】:2014-11-11 02:40:32
【问题描述】:
如果这4个字母E/A/S/T是我下面的运算符,我怎样才能使用户无法输入无效的运算符。基本上除了下面列出的以外还有什么?
print("Available Operators:")
print("'E' sets starting number")
print("'A' for addition")
print("'S' for subtraction")
print("'T' will terminate program")
# Prompt user to select the operator
choice = input("Select Operator (e/a/s/t): ")
【问题讨论】:
-
valid_entries = "e", "a", "s", "t" while true:choice = input() if selection in valid_entry: break print("请输入一个有效的字母。")