i'd like to know if it is possible to remove the negative sign from '{:,.2f}'.format(number) only using format.
So that
'{:,.2f}'.format(10) ## 10
'{:,.2f}'.format(-10) ## 10
Thanks in advance
You can't with str.format() or format() alone. Use abs() on the number instead:
'{:,.2f}'.format(abs(value))
Use abs
'{:,.2f}'.format(abs(-10))
Or lstrip:
num = -10
print '{:,.2f}'.format(num).lstrip("-")
10.00
Or:
num = -10
print 'Your number is: {:,.2f}'.format(num).replace("-","")
'Your number is: {:,.2f}' instead you have a problem than only abs() can solve..