Interesting revelation re: max() when numbers are not the same type i.e. int & float

I just discovered that max() does not return what you would expect when one entity is int and the other is float…

Strange indeed :slight_smile:

States are strings. Strings are compared from left to right. 5 > 1.

Convert your states to numbers first.

4 Likes

As @tom_l says, this isn’t int vs float but string vs string where alphabetical order trumps numerical magnitude.

In the same way that “zip” is later in the dictionary than the longer word “aardvark”, “5” is “greater” than “15.0”.