
Ben C.
asked 05/16/18How does Python compare string and int?
1 Expert Answer

Damian G. answered 01/05/21
Learning Java and Python Basics
Hi, Ben. Comparing two different data types, in this case an integer and a string results in a TypeError.
The number 2 that you put in double quotation marks("") is actually a string hence the error.
Make sure to compare numbers with other numbers, not strings that have numbers in it!
Hope this helps!
Still looking for help? Get the right answer, fast.
Get a free answer to a quick problem.
Most questions answered within 4 hours.
OR
Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.
Isaac W.
magic of python12/04/20