home
NOTE: Under Construction - I'm in the middle of upgrading my site and lots of stuff is kinda broken. Please forgive the mess.

Remove Leading Zeros From A Python String With .lstrip()

Passing a zero to .lstrip() will remove leading zeros instead of trimming leading whitespace

November 2017
Code
original = "0001234"
    
stripped = original.lstrip('0')
    
print(stripped)
Results
1234
  • Add example of .lstrip('w.') or whatever for the multiple character strip.

  • Check if doing int() also strips leading zeros

  • Either way make a version that turns the string into an int

═══ § ═══