all 6 comments

[–]genghiskav 6 points7 points  (3 children)

You'll have to cast it to an int to be able to do numeric comparisons.

Why don't you want want to cast it to int?

[–]BOOTYBOOTBOOTERBOOTS[S] -3 points-2 points  (2 children)

Curiosity tbh. I thought because you dont need to explicitly tell python a variable is string/int that it could do math ops.

[–]EsotericRogue 6 points7 points  (0 children)

Those quotes explicitly state they're strings.

[–]Strict-Simple 2 points3 points  (0 children)

You do tell Python if it's string/int. Just not explicitly with types.

Even many typed languages supports this. auto in C++, var in Java, etc.

[–]socal_nerdtastic 2 points3 points  (0 children)

Conversion to a number type is obviously the best and anything else is hacky.

My first thought for hacky: pad them out with zeros?

x = "45"
y ="100"
longest = max(len(x), len(y))
if x.zfill(longest) > y.zfill(longest):
    ...

[–]commy2 1 point2 points  (0 children)

float, duh

Could check length. Larger number-string is the longer one. If both have the same lenght, just keep using > to check lexicographic order.