vendredi 23 décembre 2016

Python - How to break while loop after empty value in a int turning input? [duplicate]

This question already has an answer here:

I want to make the while loop break when empty input is typed. I know that the error is due to the int function because it cant turn to integer an empty input but how can i do what i'm trying to write?

  while True:
    numb = int(input("number"))
    if numb % 2 == 0:
        print("this number is even")
    elif numb % 2 != 0:
        print("this number is odd")
    elif numb == '':
        break

Aucun commentaire:

Enregistrer un commentaire