0

This is my code. It is a part of the main code:

        up=input("Choose your number- ")
        c = int(up)
        if type(c)==int:
            print("The number chosen is", c)
            if c%2==0:
                print(c, "is even")
            else:
                d=c+1
                print(c, "is odd, so added one to make it even")
                print (d, "is your new number")
        else:
            print("Type a number, not a word or sentence")

As we know, the input is a string. Now, when I input a number, everything is fine. But when I input a letter, it obviously brings up an error. How do I tackle this issue so that it shows no issue? I have even tried float.

matszwecja
  • 6,357
  • 2
  • 10
  • 17

0 Answers0