The rjust() method will right align the string, using a specified character (space is default) as the fill character. ljust() is same for left allignment. txt = "banana" txt.rjust(20,'x') #txt.rjust(20,' ') is default. >>>"xxxxxxxxxxxxxxbanana"