Oct-20-2022, 05:49 AM
Quote:when a decimal number is a whole (integral, integer-like) number, it gets converted to string without the ".0"
I would say the string method of a int doesn't have the decimal, while a float does.
>>> print(int(2)) 2 >>> print(float(2)) 2.0You could always convert to an int if appropriate.
if x == int(x): x = int(x)