4 Repeat for More Input


#1

https://www.codecademy.com/courses/learn-ruby/lessons/putting-the-form-in-formatter/exercises/repeat-for-more-input?action=lesson_resume

My code is refused yet I ve declared variable each time even if it is not necessary
my code :
print "What’s your first name? "
first_name = gets.chomp

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

print"What’s your city?"
city=gets.chomp
city=“Hamburg”

print"What’s your state/province ?"
state=gets.chomp
state=“Germany”


#2

Why are you asking for user input…then setting the variable you stored it in to something else?
Take out all of your own assignment statements.


#3

I don’t understand .
How do you write in the terminal ?
Oh ! just now ! it worked ! I ve succed just now ! to write in the Terminam my name , last name , city & province . Yesterday it didn’t work .


#4

“Why are you asking for user input…then setting the variable you stored it in to something else?”
… because the error message said that the last_name was not defined . So I defined last_name first and then set it to gets.chomp . (to answer directly to your question) .
Thanks very much for your help Fight_dragons !


#5

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