# Program1: Take two numbers as input from User and print which one is greater or are they equal.
num1 = input("Enter the first number: ")
num2 = input("Enter the second number: ")
if num1 is num2:
print("The two numbers are equal")
elif num1 < num2:
print("The first number is less than the second number")
else:
print("The first number is greater than the second number")
Enter the first number: -10 Enter the second number: -20 The first number is less than the second number
Process finished with exit code 0
What is wrong in above code to compare two numbers? How come python missing basic -ve number comparison?
num1 < num2compares the strings lexicographically (basically, alphabetically). If you want to compare them numerically, you'll need to parse those strings into numbers.