Skip to content

Instantly share code, notes, and snippets.

@lf-
Last active October 21, 2024 18:48
Show Gist options
  • Save lf-/86c3944ff6cebcaece10063fbba3df91 to your computer and use it in GitHub Desktop.
Save lf-/86c3944ff6cebcaece10063fbba3df91 to your computer and use it in GitHub Desktop.
leftpad.py
class left_pad:
def __init__(this,PadChar=' ',width=4):
this.PadChar=PadChar
this.width = width
def LeftPad(this,stringToPadWithChar):
charsToPad=this.width-len(stringToPadWithChar)
OutStr=''
if(charsToPad>0):
for i in range(0,charsToPad):
OutStr=OutStr+this.PadChar
OutStr=OutStr+stringToPadWithChar
return OutStr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment