-1
a=input("Enter the first Number ")

b=input("Enter the next number ")

c=a>b

print("Is a greater than b ? ", c )  

ISSUE is it showing the opposite output always like the when you enter a greater than b it showing flase and vice versa

Gravy
  • 11
  • Input returns strings not numbers. – Mark Jul 30 '22 at 14:51
  • *input* is taken as *string*. But you're comparing *integer* numbers? How it's possible to compare then? – Daniel Hao Jul 30 '22 at 14:52
  • *"it showing the opposite output always"* - **One** test is not "always". Test different scenarios and you will observe that "5" is indeed greater than "1", but "5" is also greater than "10", but "90" is also greater than "10", etc. – David Jul 30 '22 at 14:54
  • Ohhh ! I got it !! I am a beginner ! Thanks a lot for the help ! – Gravy Jul 30 '22 at 14:54

1 Answers1

1

your problem is that you compare strings instead of floats since when you are comparing stings python compares the lexicographic value of the strings, that way "9" is grater then "12357645"

if you convert the input to float that should fix it :)

a=input("Enter the first Number ")

b=input("Enter the next number ")

c=float(a)>float(b)

print("Is a greater than b ? ", c )
Ohad Sharet
  • 1,097
  • 9
  • 15