Prompting Redux!

#1

Help. error says : you didn't add to the movie hash. here is my code:

``````movies = {"gone with the wind"=> 1, "pioneer"=> 2, "success"=> 3}
puts "enter movie choice"
choice = gets.chomp
movies = {}
movies["one"] = 1
puts 3 + movies["one"]
puts "#{title} has been added with a rating of #{rating}."
case movies
puts "Enter movie title"
title = gets.chomp
puts "Enter a rating"
rating = gets.chomp
when "update"
puts "Updated!"
when "display"
puts "Movies!"
when "delete"
puts "Deleted!"
else
puts "Error!"
end``````

#2

Before I go further, please post a link to the exercise in your original post if you can still edit it. We need to know what is being asked before going further with corrections.

#3

In its place, prompt the user for a movie title. Save the result in a new variable called title. (*Your code already has an example of how to do this!)
Next, prompt the user for the rating of the movie. Save that in a new variable called rating.
Add that movie/rating pair to the movies hash and puts a message indicating the pair was added. (No need for to_sym or to_i just yet!)
Check the hint if you need help!

?
Hint
Feel free to peek back at the first exercise if you need help!

Prompting for input looks like this:

puts "Enter a number"
number = gets.chomp
Adding a key/value pair to a hash looks like this:

numbers = {}
numbers["one"] = 1
puts 3 + numbers["one"]

prints out "4"

#4

That is actually just a hint, not a solution. Consider also that you already have a `movies` hash populated with data. We don't want to destroy that.

We still don't know for sure which lesson you are on. Please post a link to the exercise. (copy it from the location bar of that page). Thank you.

#5

This just confirms that the hash, numbers['one'] was created and has a value of 1, as given. When we add that to 3 we get 4.

We are asked to choose an action, `add` and then run the code for that case.

``````movies = {"Gone With the Wind"=> 1, "Pioneer"=> 2, "Success"=> 3}
puts "Choose an action: add, update, display, delete"
action = gets.chomp
case action
puts "Enter the movie title to add:"
title = gets.chomp
puts "Enter a rating for this title:"
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``````

This may not be what is expected but it is what I can make out from your code.

#6

This solves the problem for me .