Last active
October 21, 2024 18:48
-
-
Save lf-/86c3944ff6cebcaece10063fbba3df91 to your computer and use it in GitHub Desktop.
leftpad.py
This file contains 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