Python Forum

Full Version: exclude hyphen
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I need some help with formatting.

I am exporting data in cvs file and need to exclude hyphen and add zero in front, for example "5-" should be exported asĀ "05"

Any suggestion is appreciated, thanks!
In [11]: s = '5-'

In [12]: '0{}'.format(s.strip('-'))
Out[12]: '05'