How does >>> print( 'True' < "true") evaluate to result as True in Python? does Python consider the ASCII value for comparison? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

How does >>> print( 'True' < "true") evaluate to result as True in Python? does Python consider the ASCII value for comparison?

16th Aug 2016, 12:41 AM
Sundaresen Bhalasubramanean
Sundaresen Bhalasubramanean - avatar
2 Answers
+ 5
in ASCII 'T' = 84 and 't' = 116 so summary 'True' < 'true' then result is true
30th Aug 2016, 6:22 PM
beauty1234
+ 3
The ASCII value for 'T' is less than the value for 't'. Python does lexicographical comparisons on strings therefore since T comes before t in ASCII, True is less than true.
17th Aug 2016, 11:13 PM
Gershon Fosu
Gershon Fosu - avatar