Exercise 2: Padding and Justifying

Justify a string by padding it.

Problem statement

There’s a method that allows us to justify a string by paddingpadding it with another string.

Look for that method by skimming through the Ruby documentation for strings. Use it on the input string to accomplish the same task as before.


input_string = "ruby"
result = "ruby<3<3<3"

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy