- rjust() is a python in-build function which operate on the string to shift in the right portion and add some new character
Syntax-
str.rjust(length,fillchar)
- here length is the length of required string
- and fillchar is only one character long.
Example
string is s="mytext"
and we apply s.rjust(10,'1'), then it will become '1111mytext' of length 10, and old string is shift at right.
program-
print("Enter string")
s=input()
print("Enter character to add")
c=input()
print("Enter length of required string")
n=int(input())
print("original string is ",s)
s=s.rjust(n,c)
print("String after rjust ",s)
print("String length become ",len(s))
Enter string
mytext
Enter character to add
1
Enter length of required string
10
original string is mytext
String after rjust 1111mytext
String length become 10