Click here to navigate the course.

Drag the edges to resize the window.

In Projects, you can keep track of your progress as you go throught the tasks. Check each item as you complete it!

Code Editor
Learn
Putting the Form in Formatter

Formatting with String Methods

Great! Now we've got our output, but as you can see, we haven't used string methods to properly capitalize everything yet.

print "This is my question?" answer = gets.chomp answer2 = answer.capitalize answer.capitalize!
  1. First we introduce one new method, capitalize, here. It capitalizes the first letter of a string and makes the rest of the letters lower case. We assign the result to answer2
  2. The next line might look a little strange, we don't assign the result of capitalize to a variable. Instead you might notice the ! at the end of capitalize. This modifies the value contained within the variable answer itself. The next time you use the variable answer you will get the results of answer.capitalize
Report a Bug
If you see a bug or any other issue with this page, please report it here.