7/10 Movie Not Found


#1

I'm passing this exercise but my code isn't recognizing the movie title inside of the movies hash. It keeps skipping to "Movie Not Found!" instead of allowing me to update the rating. Code attached below, thanks in advance for any help!


movies = {
    matrix: 4,
    }
    
puts "What would you like to do?"
puts "--To add a movie type 'movie'"
puts "--To update a movie type 'update'"
puts "--To display a movie type 'display'"
puts "--To delete a movie type 'delete'"

choice = gets.chomp.downcase

case choice
when 'add'
    puts "What movie would you like to add?"
    title = gets.chomp
    if movies[title.to_sym].nil?
        puts "What would you rate this movie? 0 to 4"
        rating = gets.chomp.to_i
        movies[title.to_sym] = rating.to_i
        puts "#{title} has been added with a rating of #{rating}"
    else
        puts "That movie has already been added to the list! It's rating is #{movies[title.to_sym]}."
    end
when 'update'
    puts "What movie would you like to update?"
    title = gets.chomp
    if movies[title].nil?
        puts "Movie not found!"
    else
        puts "Please enter a new rating (0 to 4)."
        rating = gets.chomp
        movies[title.to_sym] = rating.to_i
        puts "#{title} has been updated with a new rating of #{rating}!"
    end
when 'display'
    puts "Movies!"
when 'delete'
    puts "Deleted!"
else
    puts "Error!"
end

#2

Nevermind just fixed it! I was missing .to_sym for the first part of if movies[title].nil? The correct code was if movies[title.to_sym].nil?