我正在寻求正确使用以下3个while循环的帮助:
while choice is None: ...
while not isinstance (choice, int): ...
while int(choice) not in range(0,1): ...
Run Code Online (Sandbox Code Playgroud)
也许这样的东西:
while choice is None and not isinstance (choice, int) and int(choice) not in range(0,1):
print("Invalid option!")
choice = input("Choose key: ")
Run Code Online (Sandbox Code Playgroud)
我怎么能正确地嵌套这个?
choice = None
choice = input("Choose key: ")
while choice is None:
choice = input("Choose key: ")
while not isinstance (choice, int):
print("choice is an integer and I equal 0 or 1")
print("Also if I am None or not …Run Code Online (Sandbox Code Playgroud)