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



After each variable assignment: first_name, last_name, and city add the .capitalize! method

For state use the .upcase! method

Press Run to test your code. Don’t forget to enter your answers in the console!

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?