Exercise 2: Padding and Justifying
Justify a string by padding it.
We'll cover the following
Problem statement
There’s a method that allows us to justify a string by
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.
Example
input_string = "ruby"
result = "ruby<3<3<3"
Note: This is a rather unorthodox usage of this method. Normally, we’d use it to align strings to columns so that they line up nicely when we format a table. You’ll use it in exercises later in the course to do just that!
Try it yourself
def justifying_and_padding(input_string)result = ""# Start your code herereturn resultend