Same error every time: TypeError: '<' not supported between instances of 'str' and 'int'

Question:

I want to make a tax calculator. But, before that I want to test and design my future tax calculator.
I made a test file for it.

Here is my test file:

# This is just a test to see how to design the full tax calculator

print("The data collected from you to calculate you annual tax, WILL NOT BE STORED in any way.")
print("If you are married please type 'M' in the next line or if you are single please type 'S' or if you are a head of household ")

m = input("Please type 'M' or 'S' or 'HOH' without the quote marks here: ")
if m == 'M':
    salary = input("Now please enter your salary here: ")

    if salary<19751:
        tax1 = salary/range(10.33,11.22)
        print(f"{tax1}")'

And every time I run this code I get this error:

TypeError:'<' not supported between instances of 'str' and 'int'

The line of code that gets this error is this: if salary<19751:.

Asked By: TheTheorist2359

||

Answers:

input() returns a string. A < comparison is not possible between a string and an int value (In your case, 19751). You have to cast the input like this:

salary = int(input("Now please enter your salary here: "))
Answered By: Tom Gebel
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.