We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d686864 commit 82deca3Copy full SHA for 82deca3
left_pad.py
@@ -0,0 +1,16 @@
1
+class StringUtils:
2
+ # @param {string} originalStr the string we want to append to
3
+ # @param {int} size the target length of the string
4
+ # @param {string} padChar the character to pad to the left side of the string
5
+ # @return {string} a string
6
+ @classmethod
7
+ def leftPad(self, originalStr, size, padChar=' '):
8
+ # Write your code here
9
+ result = ''
10
+ dist = size - len(originalStr)
11
+ if dist > 0:
12
+ for i in xrange(dist):
13
+ result += padChar
14
+ return result + originalStr
15
+ else:
16
+ return originalStr
0 commit comments