-1

I know the names are kind of long but I wanted to make sure there was no way it was pulling from used variables

firstvalue = input("first")
secondvalue = input("second")

if firstvalue < secondvalue:
    print ("first value is < second value")
    print ( firstvalue, "less than", secondvalue)
else:
    if firstvalue == secondvalue:
        print ("first is = second")
    else:
        print ("first is greater than 2nd")
        print (firstvalue , "greater than", secondvalue)

when i input 12 for the first value and 3 as the second value, i get 12 < 3

  • The names are long? Wait till you work in an agile business environment: `numberOfUsersThatLoggedInWithinTheLastFourWeeks` – Max Vollmer Sep 02 '18 at 11:29

3 Answers3

1

You're reading the variables as strings not integers, try this instead:

firstvalue = int(input("first"))
secondvalue = int(input("second"))
ninesalt
  • 4,054
  • 5
  • 35
  • 75
1

You are currently comparing strings and "12" is less than "3" because 1 comes before 3 in the ASCII table.

If you wish to compare the int value of the inputted string use int(input()) but then you may want to catch ValueError

gogaz
  • 2,323
  • 2
  • 23
  • 31
-1

When you input from commandline your values are text values. And remain such if you do not convert them to int or float. When comparing text values python of course compares alphabetically and so the first character is compared to the first character. Which in your example are 1 and 3 and "1" is less than "3"

Ilia Gilmijarow
  • 1,000
  • 9
  • 11