0

i'm new to python and I wrote a simple script to check if numbers given by user are eual or not. And if i put first number as 3 and second number as 10 this is happening: Console log

This is the code:

print("exercise. 1")
a = input("Enter first number: ")
b = input("Enter second number: ")

if a == b:
    print("numbers are qual")
elif a > b:
    print(a, " is bigger")
else:
    print(b, " is bigger")
Jacob
  • 11
  • 1
  • 2
    input returns `str`. You need to convert to `int` in order to compare numeric value – buran Feb 11 '21 at 18:35
  • 2
    `input` returns you a string and `'3'` is bigger than `'10'` because strings are compared lexicographically. – Asocia Feb 11 '21 at 18:36
  • 1
    Does this answer your question? [Comparing numbers give the wrong result in Python](https://stackoverflow.com/questions/39981237/comparing-numbers-give-the-wrong-result-in-python) – Countour-Integral Feb 11 '21 at 18:36
  • Also see [How to parse user input as a number](https://stackoverflow.com/questions/21262772/how-to-parse-user-input-as-a-number) to get input as number – im_baby Feb 11 '21 at 18:39
  • did you check the link provided? – buran Feb 11 '21 at 18:46
  • Okay i checked link and it works. Thank You for help! – Jacob Feb 11 '21 at 18:56

0 Answers0