Skip to content

Instantly share code, notes, and snippets.

@rroemhild
Created September 22, 2009 08:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rroemhild/190931 to your computer and use it in GitHub Desktop.
Save rroemhild/190931 to your computer and use it in GitHub Desktop.
Tidy decimal places after comma
def tidyDecimalPlaces(value):
retval = str(value)
if ',' in value:
post,pre = value.split(',')
if len(pre) == 0:
retval = "%s,00" % post
elif len(pre) == 1:
pre = "%s0" % pre
retval = "%s,%s" % (post,pre)
else:
retval = "%s,00" % str(value)
return retval
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment