Python Tells it Straight: Size Matters
It's true; Python is a size queen. It's obsessed with comparing strings, numbers, you name it. It may not make a lot of sense, though, as to how Python sees the value of different strings (uppercase Z is less than lowercase A).
To compare the size of strings, we use the < and > comparison operators, like so:
(type each of these lines at the command prompt)
'A' < 'x'
'X' > 'x'
'1' > 'z'
'$' > 'b'
'$' < '#'
It should return a True or False, depending upon whether or not the comparison is...well, true or false.
You can also try these...
'apples' > 'Apples'
'Fred' > 'fReD'
'11111' > '22222'
And of course you can use Python to compare movies as well:
'Star Trek' > 'Star Wars'
'The Matrix' > 'Star Wars'
'The Matrix' > 'Any Movie'
See? Python sure does know its movies...
The rules for which strings are bigger is like so:
blog comments powered by Disqus