LeftPad in Python

Press + to interact
def leftPad(inputStr, paddedLength, ch='.'):
if len(ch) != 1:
raise Exception('Invalid Input')
paddedLength = paddedLength - len(inputStr)
return ch * paddedLength + inputStr
print leftPad('1', 1)
print leftPad('2', 2)
print leftPad('3', 3)
print leftPad('4', 4)
print leftPad('5', 5)
print leftPad('hello', 7)
print leftPad("foo", 6)
print leftPad("foo", 3)
print leftPad("foobar", 3)
print leftPad("foo", 6, "?")