May-13-2020, 07:41 PM
input returns a str, so no matter what characters you type, the type will never be an integer.
The normal way to solve this problem is assume the user enters integers and capture the exception that gets thrown if they type something else.
The normal way to solve this problem is assume the user enters integers and capture the exception that gets thrown if they type something else.
def move_accept(z): while True: try: coords = list(map(int, input('Enter the coordiantes: ').split())) if len(coords) != 2: print('Please enter two numbers') elif not ((0 < coords[0] <= 3) and (0 < coords[1] <= 3)): print('Coordinates must be in rage 1..3') #elif playfinder test fails #print playfinder fail message else: return coords except ValueError: print('Please enter two numbers') print(move_accept(10))