You can use not
logic to check if board_size is equal to 3, 5, or 7. You can use sys.exit()
to exit the program, but make sure to import sys
.
import sys
def main():
while True:
board_size = int(input("How big playing surface (3/5/7)? "))
if not (board_size == 3 or board_size == 5 or board_size == 7):
sys.exit()
else:
break
while True:
games = int(input("How many games do you want to simulate? "))
if games <1:
sys.exit()
else:
break
while True:
scenario = int(input('What scenario (1/2)? '))
if not (scenario == 1 or scenario == 2):
sys.exit()
else:
break
print(games, scenario, board_size)
main()
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…