-
-
Save denisdefreyne/3c4d629248190bc6d6d75119f98800ee to your computer and use it in GitHub Desktop.
leftpad.py with prime indents (2, 3, 5, 7)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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