FAQ: Putting the Form in Formatter - Printing the Output

This community-built FAQ covers the “Printing the Output” exercise from the lesson “Putting the Form in Formatter”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Learn Ruby

FAQs on the exercise Printing the Output

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

1 Like

Hi mates, dont understand that … it dont run normally.
thx

ok, yeah i have the same issue.
my code looks as such:

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

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

print "What city are you from? "
city = gets.chomp

print "What state is that city in? "
state = gets.chomp

puts “Your name is #{first_name} #{last_name}, and I’m from #{city}, #{state.upcase}.”

and when i run the program it places the first question by itself and works properly, but the moment i answer it and press return, all off my other code gets executed at once and only the answer to the state question works.

i have tried using puts as opposed to print and the result is the same.

I’m having similar problems. I think the exercises are just a little buggy. If I refresh the page, it usually starts working again - if not, I just keep refreshing until it works.

1 Like

I have written the following code (as in the example), but the program does not run as intended.

print “What’s your first name?”
first_name = gets.chomp
print “What’s your last name?”
last_name = gets.chomp
print “What city are you from?”
city = gets.chomp
print “How is your (US) State abbreviated?”
state = gets.chomp

puts “Your name is #(first_name) #(last_name) and you are from #(city)”

Is it me or is the excercise still buggy?

I am having the same issue as everyone else. My code below

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

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

print "What city are you from? "
city = gets.chomp

print "What state or province are you from? "
state = gets.chomp

puts “Your name is #{first_name} #{last_name} and you live in #{city} city in #{state} state!!!”

I get the first name part but then tried to load and times out

What’s your first name? a
execution expired

Is there something going on with the compiler?

When I first did Printing the Output, I linked .capitalize! to the end of .chomp.
While it gave me a checkmark for completing the exercise, the results for answers entered without needing changes came back blank. Am just curious, why is that?
I then changed .capitalize! to its own line so the results would be correct.

Hi everyone. I found out what helped me to complete this session. I made sure that I used the quotation marks after every question that was asked. I used a set of double quotes for every set of “#{name}” “#{city}” etc. Hope that this helps. Hermanator

Hi

I’m learning #{} method right now, and I’m wondering what you would do when you have more than two of variables that you want to show continously.

if I have varibale that is “first_name” and “last_name”, and if I wanted to show “first_name” “last_name”, would I always need to put #{} on each?

like #{first_name} #{last_name}

I want to do like #{first_name last_name} but it didn’t work. Is there any way to skip writing #{} each time when you want to call lots of variables?

Im having a hard time getting my code to output properly. i know my code is correct but it only outputs the first line. ive tried logging out and restarting my computer but its not fixing the problem. its also telling me that my answer correct and to move on but i dont want to move on if i cant see my work. can anyone help me?

After you hit the “Run” button, the first line will show up in the console. You must click in the console window to focus your mouse on the console window AND then quickly type the name and press enter. If you take too long, you will get the “execution expired” error.