4. Prompting: Redux!


#1

Hi guys, I'm having trouble with this section. I keep getting different error messages; one of them including "Oops, try again. Did you create a variable called title?"
and
"(ruby):1: syntax error, unexpected ':', expecting tASSOC
'Amelie': '9',
^
(ruby):1: syntax error, unexpected ',', expecting $end"

I'm having trouble understanding what to do from the error message, and I even tried copying and pasting the model code that Codeacademy offers, just out of curiosity to see if I could pinpoint my mistake, and even that returns with an error message... So, if the model isn't even working, I feel like I'm way off...

movies = {
    'Amelie': '9',
    'Rogue_One': '10',
    'Pans_Labyrinth': '8',
}

puts "What would you like to do?"
puts " Type 'add' to add a movie."


choice = gets.chomp

case choice
when 'add'
    puts "Type in a movie title, ya jerk."
    title = gets.chomp
    puts "Give me your freakin' rating."
    rating = gets.chomp
    puts "Your freakin' movie #{title} has been added with your freakin', rating #{rating} ...jerk."
   end
when 'update'
    puts "Updated!"
when 'display'
    puts "Movies!"
when 'delete'
    puts "Deleted!"
    end
else
    puts "Error!"
end

Any tips would be much appreciated! I'm sure the answer is simple and obvious. That seems to be the pattern, but this one has me stuck...


#2

Start by removing the ' ' in your movies hash --> Amelie: 9,
That should narrow down the errors. After that you should be able to figure it out more easily.

...

PS: I love your freakin' strings.


#3

OK, I'm not even really sure how it worked, but it works now, after a few adjustments, but I did start with your tip. So, thanks! Much appreciated!
PS: freakin' thanks


#4

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