My .Capitalize isnt working


#1

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

I have tried multiple different ways to get it to work and the .capitalize has only worked with one and the system told me i have to make it in another line instead of just adding it to the end of the line of text.

print "Whats Your First Name?"
first_name=gets.chomp
first_name2 = first_name.capitalize

print "Whats Your Last Name?"
last_name+gets.chomp
last_name2 = last_name.capitalize

print "What City Are You From?"
city=gets.chomp
city2 = city.capitalize

print "What State Are You From? (please use abbreviations)"
state=gets.chomp.upcase

puts "Your name is #{first_name}!"
puts "Your Last Name is #{last_name}!"
puts "You live in #{city}"
puts "You live in #{state}"

#2

Did you mean to write, last_name = gets.chomp?


#3

@arcslayer52915
AND
you might want to use

puts "You live in #{city2}"

#4

yes. i fixed it and that is still not working


#5

@arcslayer52915
The instructions::
01. After each variable assignment: first_name, last_name, and city add the .capitalize! method
02. For state use the .upcase! method

You are asked to use .capitalize! with the exclamation marker
which indicates that variable itself , on which you perform the .capitalize method
So instead of for example
you using

city2 = city.capitalize

you could use

city.capitalize!

therewith changing the city variable itself is capitalized.

== discussions / opinions ==
http://stackoverflow.com/questions/612189/why-are-exclamation-marks-used-in-ruby-methods
http://stackoverflow.com/questions/7179016/what-is-the-purpose-of-and-at-the-end-of-method-names
http://stackoverflow.com/questions/25293302/why-do-some-ruby-methods-need-a-bang-and-others-dont-to-be-a-destructive-method


#6

Thank you very much. that fixed it.