Comparing numbers give the wrong result in Python

前端 未结 4 1929
余生分开走
余生分开走 2020-11-29 12:59

If I enter any value less than 24, it does print the \"You will be old...\" statement. If I enter any value greater than 24 (ONLY up to 99), it prints the \"you are old\" st

4条回答
  •  孤独总比滥情好
    2020-11-29 13:02

    The string '100' is indeed less than the string '24', because '1' is "alphabetically" smaller than '2'. You need to compare numbers.

    my_age = int(input())
    if my_age > 24:
    

提交回复
热议问题