dimanche 30 mai 2021

my code give an error if a enter a letter or a charcter different to a float or integer

my purpose is to return a message if the user enter a letter or character different to an integer or float but if a enter a letter like "jhdsjfhdhjd" it give me an error

 my_number = int(input("Please ,enter your number here !"))
if my_number is not int:
    print("It is not a number a number !")
else:
    my_num = int(my_number)
    if my_num == 0:
        while my_num < 11 :
            print("Not there Yet , your number is " + str(my_num) + ".We continue increase your number to 10 !")
            my_num +=1
        print("Good, increasing is Done , the number is 10")
    elif my_num > 0:
        while my_num > -1:
            if my_num == 0:
                print("Correct ,the decreasing is finished.The number is 0")
        print("Not there Yet , your number is " + str(my_num)+ ".We continue decrease your number to 0 !")
        my_num -=1
    else:
        print("It isn't a number ,Please enter an integer")


   

Aucun commentaire:

Enregistrer un commentaire