4.Prompting: REDUX!


it looks like you didn’t add to the movies hash
I get stuck in here

movies = {
  Fast_and_Furious: 4,
  Snipper: 3.5,
  Transformer: 2.5
puts "What movie do you like?"
choice = gets.chomp

case choice
  when "add"
  	puts "What movie do you want to add?"
  	title = gets.chomp
  	puts "What's the rating? (type 0 - 5.)"
  	rating = gets.chomp
movies[title] = rating
  puts "#{title} has been added with rating of #{rating}"

  when "update"
  	puts "Updated!"
  when "display"
  	puts "Movies!"
  when "delete"
  	puts "Deleted!"
  	puts "Error!"



Hi @shippo2017 :smiley:
It gives you that error because you forgot to append the new movie and rating in the movies hash.
You can do so by adding in the add case:

if movies[title.to_sym].nil? {
    # the rating code
    movies[title.to_sym] = rating.to_i # adds the new movie and rating with bracket notation to movies hash


Hope this helps!!!


I write ‘add’ in the user input.
it worked


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