-2

Is '2' > '10'? What is the output if we compare two integers which are converted to string format?

I am getting true but it's false, right?

enter image description here

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
naveen
  • 23
  • 1
  • 5

1 Answers1

1

When comparing strings, you compare them lexicographically. The character 2 comes after the character 1, so the result is True. The fact that these two strings could be converted to integers is inconsequential.

Mureinik
  • 297,002
  • 52
  • 306
  • 350