Oops, try again. It looks like you didn't add to the movies hash!


#1

This is my code:

movies = { 
  "Die Hard" => 4.5,
  "Lord of the Rings" => 4.4
}

puts "What is a movie you have seen?"
choice = gets.chomp

case choice
when 'add'
  puts "What is the name of the movie you wish to rate?"
  title = gets.chomp
  puts "What do you rate the movie (out of 5)?"
  rating = gets.chomp
  movies[title] = rating
when 'update'
  puts "Uddated!"
when 'display'
  puts "Movies!"
when 'delete'
  puts "Deleted!"
else
  puts "Error!"
end

However I am still getting the error "Oops, try again. It looks like you didn't add to the movies hash!"

I have double-checked and the only way that we have been shown so far to add to a hash is the my_hash[key] = value syntax. so what am I missing?


At the Movies: 4-10; Prompting Redux
#2

Haha - I worked it out - my code was fine - I just needed to follow through and type 'add' so the code could run properly!!


#3

yeah, that's misleading in the lesson.


#4

Yeah - the directions are very unclear, since in the second step they tell you to just write any question when in fact they're expecting you to copy the first 'puts' that is shown at the beginning.

This is not the first set up unclear directions in this track. Very disappointing.


#5

I ran into the same problem. Then I defined title as a symbol
title = {}

before the case section, then it worked. Hope this helps.