Occurs when comparing a string with an integer.
age = input("Enter your age: ")
if age > 18:
print("Allowed")Enter your age: 20
Traceback (most recent call last):
File "reproduce.py", line 3, in <module>
if age > 18:
^^^^^^^^
TypeError: '>' not supported between instances of 'str' and 'int'
age = int(input("Enter your age: "))
if age > 18:
print("Allowed")I thought entering a number would be treated as a number, but input() always returns a string. Converting it to int fixed the issue.