Make sure to call capitalize on first_name last_name and city


I am able to get the correct output but the i am getting the error message.
So how exactly we are supposed to approach this problem

print "What's Your first name?"
first_name = gets.chomp.capitalize
print "What's your last name?"
last_name = gets.chomp.capitalize
print "Which city are you from?"
city = gets.chomp.capitalize
print "Which state are you from?"
state = gets.chomp.upcase

puts "#{first_name} #{last_name} #{city} #{state}"

I have also tried the following
first_name = first_name.capitalize
last_name = last_name.capitalize
city = city.capitalize
state = state.upcase
puts "#{first_name} #{last_name} #{city} #{state}"


puts "#{first_name.capitalize} #{last_name.capitalize} #{city.capitalize} #{state.upcase}"


Your code is correct, but the instructions clearly stated that you should use mutating methods (with exclamation mark).

You have to change .capitalize to .capitalize! and .upcase to .upcase!.


Thanks. I will read instructions carefully from now on.


You're very welcome :slight_smile:


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.