vendredi 27 septembre 2019

How do i check if the input of the user is empty? And if it is, how will ask for another input?

I've been trying this code but i think the move == " " doesnt work because i've tried to use the move > grid_width or move <0 part only and it works fine. I want to ask the user for another input if he/she didn't type any input but still pressed enter on the input getter.

 while True:
        try:
            move= int(input('Enter your move: '))
        except ValueError:
            print('Please enter a valid input.')
        if move > grid_width or move < 0 or move == " ":
            print('Please enter a valid input.'))
            continue
        break

Aucun commentaire:

Enregistrer un commentaire