I'm an inexperienced programmer. I'm trying to remove trailing zeros from a whole number, an integer, for a project I've set myself in python.
I have managed to do this but there must be a better way than the monstrosity I have concocted!
def removeZeros(number):
return int(str(int(str(number)[::-1]))[::-1])
Essentially I'm turning the integer into a string, reversing the string, turning it back into an integer---which removes the now leading zeros, turning it back into a string and reversing it; and finally turning it back into an integer to return it.
Any help would be appreciated.