Tells me I need to capitalize: name, last name, and city


#1

In the sixth exercise, Formatting with string methods, I have an issue with my code. I have typed everything in and the editor is correct and I've capitalized like I'm supposed to, but the ending where it says correct or incorrect tells me I need to capitalize: name, last name, and city. Will someone help me?

Here is my code.

    print "What's your first name?"

answer = gets.chomp.capitalize
print "What's your last name?"
answer = gets.chomp.capitalize
print "What city do you live in?"
answer = gets.chomp.capitalize
print "What state do you live in?"
answer2 = gets.chomp.capitalize
puts "Your name is #{first_name} #{last_name}."
puts "You live in #{city}, #{state}."


#2

Let's have a look at what you are asking your program to print:

puts "Your name is #{first_name} #{last_name}."
puts "You live in #{city}, #{state}."

You are having a problem, because nowhere in your previous code have you set a value for any of those variables. There is no:

first_name = 
last_name =
city = 
state =

You haven't set a value for those variables so you can't use them when it comes to your puts commands.

Do you understand the problem now?