Ruby 1.4 Repeat for more input


here is my code:

print "What's your first name?"
first_name = gets.chomp

print "What's your last name?"
last_name = gets.chomp

print "What city do you live in?" 
city = gets.chomp

print "What state/province do you live in?"
state = gets.chomp

can someone please tell me what I'm doing wrong? It keeps saying error and asking if I declared a variable "last_name"


Unable to reproduce error with direct paste in of above code. Are you entering data at the prompts?


Yes I am, but it still won't take my code.


I got it to where it doesn't say error anymore but the gear gif just spins. I had this problem the last three exercises I did.


Are you running an app or a desktop version of CC?


desktop version. Is there an app I can download?


I don't know that for certain, though it's a good possibility. What all is included in Pro accounts is unknown to me. If there is an app, that's where I would look for it.

What browser/OS are you using?


I am using google chrome


Passed again in Chrome/Windows 7


I have Windows 10 unfortunately


I'm out of suggestions. These are some re-do considerations:

  • go back a lesson, submit and proceed
  • refresh the page
  • reset the lesson
  • clear cookies
  • clear CC from history
  • switch browser

The latter three are last resort, and I have never cleared cookies or history so don't know how or if that will help.


Thank you I will take those under consideration.


There is something wrong with the instructions on this one. Because once you correctly run the code it puts the first name out of order.

I got it done by trial and error. You need input the follow

first_name = gets.chomp
print "First Name"
last_name = gets.chomp
print "Last Name"
city = gets.chomp
print "City"
state = gets.chomp
print "State"


This is what worked for me, after a zillion error messages and two or three offers to give up and get code. :stuck_out_tongue:

print "What's your first name?"

print "Last Name"

print "City"

print "What's the abbreviation for your State?"


puts "Your name is #{first_name} #{last_name} and you are from #{city}, #{state}."

At one point, the wheel stopped turning frantically and exercise got validated BUT the terminal did not really show the abbreviated state in .upcase!

Now it gives:
What’s your first name?pepa
Last Namepig
What’s the abbreviation for your State?ny
Your name is Pepa Pig and you are from Paris, NY.

OT: I would LOVE to add a space after the prompt but I’m learning to accept stuff, like I don’t yet know how to and also, was not required…

Hope that helps.

print "What's your first name? "

print "Last Name: "

print "City: "

print "What's the abbreviation for your State? "


print "What’s your first name? "
print "Last Name: "
print "City: "
print "What’s the abbreviation for your State? "

oh my, the endlessly spinning little green thingy and trial-erroring killed my brain. you add a space by adding a space, duh.

thanks! :slight_smile: