0

When I run this code, the value of H is false. I used sys.getsizeof() function and S5 = 29 and S6 = 33 came out. I don't get it why S5 >S 6 ?

S5 = "ants"
S6 = "anteater"

H = S5 < S6
print( "Value of H:", H )
Jules Dupont
  • 6,591
  • 7
  • 36
  • 37

2 Answers2

1

Strings are compared lexicographically using the numeric equivalents (the result of the built-in function ord()) of their characters. Unicode and 8-bit strings are fully interoperable in this behavior.

For more details check this

Nitheesh MN
  • 558
  • 7
  • 17
0

What are you trying to do? Are you trying to calculate the size of both strings? To calculate the size of a string, do myLength = len("myString"). You can then add the result from both strings if you wish to do so.

Hope this helps.

Arnev Sai
  • 131
  • 2