In Python ” TypeError: ‘>=’ not supported between instances of ‘str’ and ‘int’ ” we face this message when we try the string and integer compare or use >= Greater than or equal to then we face this error. For example, if you want to compare the sting ( “40”) with the integer (40) but in simple language sting (“40”) is a text, not a number but the integer (40) is the number and in python, we are not able to compare or use >= Greater than or equal to because this is string(“text”) and integer (40) number. To fix this error we need to convert the string into an integer.
Wrong Code
print("Welcoml to the Amol BLog love Calculator!")
name1 = input("What is Your Name?\n")
name2 = input("What is their name?\n")
combined_string = name1 + name2
lower_case_string = combined_string.lower()
t = lower_case_string.count("t")
r = lower_case_string.count("r")
u = lower_case_string.count("u")
e = lower_case_string.count("e")
true = t + r + u + e
l = lower_case_string.count("l")
o = lower_case_string.count("o")
v = lower_case_string.count("v")
e = lower_case_string.count("e")
love = l + o + v + e
love_score = str(true) + str(love)
if (love_score >= 90) or (love_score < 10):
print(f"Your love score is {love_score}, you go together like code and mentors.")
elif (love_score >= 40) and (love_score <= 50):
print(f"Your love score is {love_score}, you are alright together.")
else:
print(f"Your love score is {love_score}.")
Error Massage
What is Your Name?
Amol
What is their name?
Jennifer
Traceback (most recent call last):
File "/home/kali/python/webproject/error/main.py", line 24, in <module>
if (love_score >= 90) or (love_score < 10):
TypeError: '>=' not supported between instances of 'str' and 'int'
Wrong code line
love_score = str(true) + str(love)
Correct code line
love_score = int(str(true) + str(love))
- Wrong action: love_score = str(true) + str(love)
- Correct action: love_score = int(str(true) + str(love))
- Convert Str into an int.
Entire Correct Code line
print("Welcoml to the Amol BLog love Calculator!")
name1 = input("What is Your Name?\n")
name2 = input("What is their name?\n")
combined_string = name1 + name2
lower_case_string = combined_string.lower()
t = lower_case_string.count("t")
r = lower_case_string.count("r")
u = lower_case_string.count("u")
e = lower_case_string.count("e")
true = t + r + u + e
l = lower_case_string.count("l")
o = lower_case_string.count("o")
v = lower_case_string.count("v")
e = lower_case_string.count("e")
love = l + o + v + e
love_score = int(str(true) + str(love))
if (love_score >= 90) or (love_score < 10):
print(f"Your love score is {love_score}, you go together like code and mentors.")
elif (love_score >= 40) and (love_score <= 50):
print(f"Your love score is {love_score}, you are alright together.")
else:
print(f"Your love score is {love_score}.")
What is TypeError: ‘>=’ not supported between instances of ‘str’ and ‘int’?
In Python, we face this message when we try the string and integer compare or use >= Greater than or equal to > symbol for mathematical calculation and in python we are not able to compare str and int that’s why we face this error.
How to fix TypeError: ‘>=’ not supported between instances of ‘str’ and ‘int’?
To fix this error we need to convert the string into an integer then we are able to compare or use >= Greater than or equal to the symbol for int to int not str to int, for more clarification please see the above example.
For more information Visit YouTube Channel.

