I\'m looking for a way to convert numbers to string format, dropping any redundant \'.0\'
The input data is a mix of floats and strings. Desired output:
0
def floatstrip(x): if x == int(x): return str(int(x)) else: return str(x)
Be aware, though, that Python represents 0.1 as an imprecise float, on my system 0.10000000000000001 .