Number 7 doesn't accept "update"


#1

Hello! I choose "update", successfully update the movie and then I get this massage :
"Oops, try again. Make sure to test your program by choosing 'update'. "

Here is my code:

movies = {
Memento: 4.5,
Fargo: 5.0,
Birdman: 5.0,
Seven: 4.5
}
puts "Add choise"
choise = gets.chomp.downcase
case choise

when "add"
title = gets.chomp
rating = gets.chomp
if(movies[title.to_sym]==nil)
movies[title.to_sym] = rating.to_i
puts "Added!"
else
puts "Movie already in"
end

when "update"
puts "What is your movie to update?"
title = gets.chomp
if movies[title.to_sym].nil?
puts "Error: Movie non-existent."
else
puts "What is your new rating?"
rating = gets.chomp
movies[title.to_sym] = rating.to_i
end
when "display"
puts "Movies!"
when "delete"
puts "Deleted!"
else
puts "Error!"
end


#2

Same. Pretty annoying.


#3

My code works fine, but I have same error message and can't go next!!! Please help!!!
My code:

movies = {
sence8: 4,
jesica_jones: 4,
forever: 4}

puts "Use command:"
puts "add"
puts "update"
puts "display"
puts "delete"
command = gets.chomp

case command
when "add"
puts "Enter the movie title"
title = gets.chomp.to_sym
if movies[title].nil?
puts "Enter the movie rating"
rating = gets.chomp.to_i
movies[title] = rating
puts "#{title} with rating #{rating} was added to movies list"
else
puts "Movie already exists "
end
when "update"
puts "Enter the movie title"
title = gets.chomp.to_sym
if movies[title].nil?
puts "Movie not found!"
else
puts "Enter new movie rating"
rating = gets.chomp.to_i
movies[title] = rating
puts "Movie #{title} rating was updated"
end
when "display"
puts "Movies!"
when "delete"
puts "Deleted!"
else
puts "Error!"
end


#4

Me too: code works. I can even print out the updated hash at the end, and it just tells me to test it by choosing 'update'. Too bad. I've been enjoying the course, but now I can't move on.


#5

Just skip that lesson and go for the next. When you will pass the next lesson go back and submit previous. And you will pass this one


#6

check out my code, it's working

movies={ spiderman: 5,
captain: 4}
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 "Add your movies here"
title = gets.chomp

puts "Add your rating here"
rating = gets.chomp
if movies[title.to_sym].nil?
movies[title.to_sym]= rating.to_i
puts " your movie and rating has been added #{title}: #{rating}"
else
puts " the movies already in the hash"
end

when "update"

puts "What movie do you want to update"
title = gets.chomp
if movies[title.to_sym].nil?
puts "error, the movie is not in the hash"
else
puts " add new rating to your movie"
rating = gets.chomp
movies[title.to_sym]= rating.to_i
puts " #{title} has been update to #{rating}"
end

when "display"
puts "Movies!"
when "delete"
puts "Deleted!"
else
puts "Error!"
end