I need to get the last 2 digits of integers and decimals.
I'm using number%100
operator to get the last 2 digits of an integer. However, I get an error when I try the same on a decimal.
Is there any simple way to do it, without converting to a string and parsing?
Example:
number = 1234.56789
I need to get 89.
56789 % 100 = 89
1234.56789 % 100
gives error:
ValueError: invalid literal for int() with base 10
More examples:
number = 0.1
I need to get 0.1
(with the decimal).