[Python] How do I compare a string and an integer? [duplicate]

Discussão em 'Python' iniciado por Stack, Agosto 8, 2025.

  1. Stack

    Stack Membro Participativo

    I am quite a newbie in Python. I wrote this and got this error when i typed a letter in the input:

    TypeError: unorderable types: str() >= int()


    Here is the code that I wrote:

    user_input = input('How old are you?: ')
    if user_input >= 18:
    print('You are an adult')
    elif user_input < 18:
    print('You are quite young')
    elif user_input == str():
    print ('That is not a number')

    Continue reading...

Compartilhe esta Página