String Rjust in Python

Level 254 keystrokes

This right-justifies a string within a specified width, padding with a character on the left.

Python code

# Create a short string
1text = "Hi"
# rjust(width, char) pads the string to the specified width
# The string is right-aligned, padding goes on the left
2padded = text.rjust(10, "*")
# Print the padded string (8 asterisks followed by Hi)
3print(padded)

Output

********Hi
Practice typing this code

Practice typing this code. Results are not recorded in the rankings.

Symbols in this code

The symbols you type in this Python code and how often they appear.

  • "× 4
  • (× 2
  • )× 2
  • =× 2
  • ,× 1
  • .× 1
  • *× 1

More Python examples at level 2

← Python typing practice