Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def comma(n):
- istring = str(n)
- split = istring.split(".")
- if len(split) > 1:
- return comma(int(split[0])) + "." + comma(int(split[1])) #recursive decimal handling
- ostring = ""
- count = 0
- for i in range(len(istring)-1,-1,-1): #for(int i = len(istring); i >= 0; i--)
- if count == 3:
- ostring = "," + ostring
- count = 0
- ostring = istring[i] + ostring
- count += 1
- return ostring
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement