For example, to check if they are greater than, lesser than or equal to each other without using int() and def.
num1 = "67"
num2 = "1954"
Left pad with zero and then compare the strings lexicographically:
num1 = "67"
num2 = "1954"
if num1.zfill(10) < num2.zfill(10):
print("67 is less than 1954")
Note here that the left padding trick leaves the 2 numbers with the same string length. So we are doing something like comparing 0067 to 1954, in which case the dictionary order is in agreement with the numerical order.
Easiest without padding to an unknown length:
if (len(num1), num1) < (len(num2), num2):
print(num1, "<", num2)
(2, "67") < (4, "1954"). Tuple comparison works lexicographically, as well, in that the second elements are only compared if the first elements are the same. Hence, shorter numbers will always be considered smaller. Numbers of equal length will be compared alphabetically.num1 = '4'; num2 = '03'.
int?