Computer Science, asked by skmittal7202, 10 months ago

Explain Parameters of str.rjust(width[, fillchar])

Answers

Answered by cutygirl22
0

WHAT'S YOUR QUESTION

ASK PROPERLY ✌️✌️

Answered by letmeanswer12
0

Python str.rjust parameter width is for total string length and fill char is the filler.

Explanation:

The Python method rjust() returns a right-justified string with the length width. The fillchar defined is used for padding, and the default taken as space. In case of width is less than the length of the specified string then the original string is returned.

  • Syntax - str.rjust(width[, fillchar])
  • Parameters - (width) − Specifies the total length of the string after padding.

(fillchar) − Specifies the filler character, and the default taken as space.

  • Return Value - It returns a string right-justified with the specified length width.

Example

  • #!/usr/bin/python
  • str = "this is string rjust example.";
  • print str.rjust(40, '$')

Output

  • $$$$$$$$$$$this is string rjust example.

In the example, the string length is 40 characters and is padded with $ as specified.

Similar questions