home ~ projects ~ socials

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

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

original = "0001234"
    
stripped = original.lstrip('0')
    
print(stripped)
Output:
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
-- end of line --