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 )
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 )
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
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.