Can't pass 7/10 A Night at the Movies


#1

link to the exercise: https://www.codecademy.com/courses/learn-ruby/lessons/a-night-at-the-movies/exercises/update?action=lesson_resume&link_content_target=interstitial_lesson

When i run my program no error messages appear but can’t i can’t pass the 7th test. I compare my code with the example code on the 1st page of this project ( “A Night at the Movies” ) it looked the same. Tried to refresh the page but it didn’t change the situation. Will be very grateful for any help

`movies = {
  memento: 3,
  batman: 4
  }

puts "Print command: "
puts "<--- add a movie"
puts "<--- update list of movies"
puts "<--- display all list of movies"
puts "<--- delete a movie from the list"
command = gets.chomp.downcase

case command
  when "add"
#    puts "Added!"
    puts "Enter title: "
    title = gets.chomp.downcase
    if movies[ title.to_sym ].nil?
      puts "Enter rating: "
      rating = gets.chomp
      movies[ title.to_sym ] = rating.to_i
    else
      puts "Movie is already in the list"
    end
  when 'update'
#    puts "Updated!"
    puts "Enter title to update: "
    title = gets.chomp.downcase
    if movies[ title.to_sym ].nil?
      puts "Movie not found!"
    else
      puts "What's the new rating? (0 to 4)"
      rating = gets.chomp
      movies[ title.to_sym ] = rating.to_i
#      puts "#{title} has been updated with new rating of #{rating}"
    end
  when "display"
    puts "Movies!"
  when "delete"
    puts "Deleted"
  else
    puts "Error!"
end`

#2

Our code (yours and mine) differs in the first few lines:

movies = {
  :Crash => '4',
  :Babel => '4'
}
puts "your command: "
choice = gets.chomp
case choice

Note how the hash is written. symbol => value. May or may not have a bearing. Note also the use of choice as the variable.

your command: 
update
Movie title: 
Crash
Movie rating: 
3.5
Crash updated with rating 3.5.

#3

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