python remove trailing 0 code example
Example 1: remove trailing zeros python
var = round(var, 1) #the first value is the number or var
#to round, the second is what desimal to round to
Example 2: python remove .0
number = 5.0
number = int(number)
# 5
# Safety net if number is not equal to int
def safe_int(number: float):
if number - int(number) == 0:
return int(number)