Skip to content

Instantly share code, notes, and snippets.

@denisdefreyne
Forked from lf-/leftpad.py
Last active October 21, 2024 18:50
Show Gist options
  • Save denisdefreyne/3c4d629248190bc6d6d75119f98800ee to your computer and use it in GitHub Desktop.
Save denisdefreyne/3c4d629248190bc6d6d75119f98800ee to your computer and use it in GitHub Desktop.
leftpad.py with prime indents (2, 3, 5, 7)
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