mardi 18 août 2020

Else statement not executed with string or float input

num1 = int(input("Enter the first integer: "))
num2 = int(input("Enter the second integer: "))  

if (str(num1).isdigit()) and (str(num2).isdigit()):
    if num1>num2:
        print(num2, num1)
    else:
        print(num1, num2)
else:
    print("That is not an integer!")

Error that I am getting:

Traceback (most recent call last):

File "C:\Users\shrad.spyder-py3\temp.py", line 183, in num2 = int(input("Enter the second integer: "))

ValueError: invalid literal for int() with base 10: '2.2'

Aucun commentaire:

Enregistrer un commentaire