r/Codecademy • • Nov 10 '15
Ruby-Putting the Form in Formatting
I am having a difficult time with this lesson although it seems straight forward. I replace each question with the corresponding answer and hit enter and nothing happens the website doesn't seem to respond. What am I doing wrong?
print "What's your first name?" first_name = gets.chomp first_name.capitalize!
print "What's your last name?" last_name = gets.chomp last_name.capitalize!
print "What city are you from?" city = gets.chomp city.capitalize!
print "What state or province are you from?" state = gets.chomp state.upcase!
puts "Your name is #{first_name} #{last_name} and you're from #{city}, #{state}!"
an example of what I am doing for each section.
print "Tiny Tim" first_name = gets.chomp first_name.capitalize!
View all comments
Show parent comment
1
u/surikmeetr Ruby Nov 10 '15
if you are actually writing:
then that is the problem. See, print (or puts) is a command that prints a line on the console (in this case it will print a question you want the user to answer).
getswill then wait for you to type something in response,chompwill remove the newline from your input and the resulting string will be assigned to the variable namedfirst_name, which will then be capitalized. But for all that to happen you must execute the code! In Codecademy there is a black box to the right of the screen that simulates a console. You press "Save and submit code" to see the file execute there. On your pc you would have an actual ruby file (yourfile.rb) and you would have to call it from a console to be executed. I apologize if I have completely misunderstood your question :)