It looks like you didn't add to the movies hash! 4. Prompting: Redux!


#1

Please, help me, I have a problem in Prompting: Redux! This is my code:

movies= {
'independence day' => 4,
'dracula' => 3,
'matrix' => 5
}
puts "What is your movies choice?"
choice = gets.chomp.downcase

case choice
when "add"
puts "Please specify movies title"
title = gets.chomp
puts "Please rating the movies from 0 to 4"
rating = gets.chomp
movies[title] = rating
puts "#{title} has been added with a rating of #{rating}."
when "update"
puts "Updated!"
when "display"
puts "Movies!"
when "delete"
puts "Deleted!"
else
puts "Error!"
end

When I pushed sent this is the message send me: "It looks like you didn't add to the movies hash!"

I need any help to pass the other topic....................
Thank you


#2

Your code seems fine.

Please note that you have to answer add to the first question and then input movie data. This is important, because SCT (tests used to check if your code is correct) checks if variables title and rating are defined.


#3

I still continued with the problem I do not how I can change this code..... It is difficult for me.


#4

Thank good I resolved. This is the new code I added.........

movies= {
'independence day' => 4,
'dracula' => 2,
'matrix' => 6
}
puts "What is your favorite movies choice?"
puts "What would you like to do?"
puts "-- Type 'add' to add a movie."
puts "-- Type 'update' to update a movie."
puts "-- Type 'display' to display all movies."
puts "-- Type 'delete' to delete a movie."
choice = gets.chomp.downcase

case choice
when "add"
puts "What movie do you want to add?"
title = gets.chomp
puts "What's the rating? (Type a number 0 to 4.)"
rating = gets.chomp
movies[title.to_sym] = rating.to_i
puts "#{title} has been added with a rating of #{rating}."
when "update"
puts "Updated!"
when "display"
puts "Movies!"
when "delete"
puts "Deleted!"
else
puts "Error!"
end :smile:


#5

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