Make sure to call capitalize on first_name last_name and city


#1



https://www.codecademy.com/courses/ruby-beginner-en-MxXx5/0/6?curriculum_id=5059f8619189a5000201fbcb


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}"

=begin 
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}"

And

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


#2

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!.


#3

Thanks. I will read instructions carefully from now on.


#4

You're very welcome :slight_smile:


#5

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