Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Currency Style solution in Uncategorized category for Currency Style by capback250
# migrated from python 2.7
def checkio(string):
out = []
for patt in string.split(" "):
if "$" in patt and len(patt) > 2:
lastPoint = '.' if patt[-1] == '.' else ''
splitted = list(filter(bool, patt[1:].replace(',', '.').split('.')))
if len(splitted) == 2:
if len(splitted[-1]) == 2:
out.append("$"+'.'.join(splitted)+lastPoint)
else:
out.append("$"+','.join(splitted)+lastPoint)
if len(splitted) > 2:
if len(splitted[-1]) == 2:
out.append("$"+','.join(splitted[:-1])+'.'+splitted[-1]+lastPoint)
else:
out.append("$"+','.join(splitted)+lastPoint)
else:
out.append(patt)
return ' '.join(out)
Jan. 30, 2016