Need help with Printing the Output on Ruby


#1

The system keeps telling me that my syntax does not look right but I can't figure out why. Can someone please help? It also says::

(ruby):4: syntax error, unexpected tCONSTANT, expecting $end
print "What city are you from?"
^

print "What's your first name?"
Matthew=gets.chomp
print "What's your last name?
Vega-Sanz=gets.chomp
print "What city are you from?"
Miami=gets.chomp
print "What state are you from?
Florida=gets.chomp
first_name = "Matthew"
puts "#{first_name}"
puts "What is your #{first_name}?"
last_name = "Vega-Sanz"
puts "#{last_name}"
puts "What is your {last_name}?"
city = "Miami"
puts "#{city}"
puts "What #{city} are you from?"
state = Florida
puts "#{state}"
puts "What #{state} are you from?"


#2

To solve that particular question, you will find the problem on the above line. - Can you spot it?

Also, let's look at what you are doing here:

print "What's your first name?"
Matthew=gets.chomp
first_name = "Matthew"
puts "#{first_name}"
puts "What is your #{first_name}?"

If I were running your program, and the "What's your first name?" prompt showed up on my screen, I would answer with AlbionsRefuge.

Looking at your second line, what would then make:

Matthew = "AlbionsRefuge"

Doesn't that seem a bit odd, maybe not like quite what you were planning?

Then on these next three lines you do this:

first_name = "Matthew"
puts "#{first_name}"
puts "What is your #{first_name}?"

What if it were me again running your program? That would print

Matthew

which would be a bit confusing for me. And then right away, after printing Matthew, it would print:

What is your Matthew?

There must be a better way to:
- ask me my name
- store it in first_name
- print a nice sentence back to me using first_name

:green_heart:

Now, I wonder, why did we do the whole

Matthew = gets.chomp
first_name = "Matthew"

thing?

Why not just do first_name = gets.chomp?


#3

thanks for the reply. The first 8 lines were part of the exercise prior to this one. it was the section, "Repeat for More Input" so I am not sure that is the problem. I think the problem lies within lines 9 through 20. Line 9 is,
"first_name = "Matthew".
It continues to tell me that my syntax is wrong and also tells me:

(ruby):4: syntax error, unexpected tCONSTANT, expecting $end
print "What city are you from?"
^


#4

You are getting that because this line is missing a ":

print "What's your last name?