I'm right, right?


#1



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


"Oops, try again. Did you declare a variable called last_name?"
For your information, I did declare a variable called last_name. I copy-pasted the code of what your first name is to the areas designated to last name, city, and state, changing the questions and variable name to what the instructions asked. I don't understand what I did wrong or if I did anything wrong!
I used literally every thing I could think of, following the instructions perfectly. My instructor is unwilling to offer assistance. Is there something wrong with my code, my account, or the instructions? Your help will be greatly appreciated.

print "What's your first name?"
variable_first_name=gets.chomp
print "What's your last name?"
variable_last_name=gets.chomp
print "What city do you live in?"
variable_city=gets.chomp
print "What is the abbreviation of your state or province?"
variable_state=gets.chomp


#2

Why have you declared the variable which collects the input as:
variable_` ?

The courses can at times be very fussy about doing things exactly as instructed. In this case, although your code would technically work, it's not what they requested. For example:

print "What is your name? "
first_name = gets.chomp

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

It's looking for the variable"last_name" , which if you tried it this way would work.

In short to declare a simple variable in Ruby you do not need to state it's a variable:

first_name = "nerdywritergirl" -- This is perfectly fine


#3

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