6/10 - error error excercise issue


Here is the link to the exercise i am stuck at https://www.codecademy.com/courses/learn-ruby/lessons/a-night-at-the-movies/exercises/error-error?action=lesson_resume

My code works, in the sense that it lets me add a rating and a title and I get a checkmark as well and I can proceed to the next exercise, but when I try to add the movie that is already in the hash, I don’t get the else statement saying “This movie was already added”…what is wrong here.

  "shawshanks_redemption" => 5,

puts "What would you like to do?"
puts "Do you want to add a movie? Type Add"
puts "Do you want to rate a movie? Type Rate"
puts "Do you want to delete a movie? Type Delete"
puts "Do you want to change display all movies? Type Display"
choice = gets.chomp.downcase

case choice
  when "add"
     puts "Add a movie"
      title = gets.chomp
  if movies[title.to_sym].nil?
     puts "Add a rating"
      rating = gets.chomp
    movies[title.to_sym] = rating.to_i
    puts"This movie already exists. It's rating is #{movies[title.to_sym]}"
  movies[title] = rating
  when "update"
     puts "Updated!"

I haven’t shown all the code because it is just the case statements and they are correct so far because nothing has been done to them.

Anyways why is it not giving the else statement when I type shawshanks_redemption?



Because it is not a symbol in your hash.


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