Delete: unexpected keyword_when, expecting $end when "delete"


#1



https://www.codecademy.com/courses/ruby-beginner-en-0i8v1/0/9?curriculum_id=5059f8619189a5000201fbcb#


Hello everyone, I am still getting this error message and can not figure it out ! Anyone can help ?
(ruby):38: syntax error, unexpected keyword_when, expecting $end
when "delete"


movies = {
    HarryPotter: 9,
    TotallySpies: 3,
    JustOneLook: 5
}

puts "What do you want to do ? "
choice = gets.chomp

case choice

when "add"
puts "Enter a movie title"
title = gets.chomp
 if movies[title.to_sym].nil?  
puts "Enter a rate"
rating = gets.chomp
puts "#{title} and #{rating} added!"
movies[title.to_sym] = rating.to_i
else
    puts "movie already exists !"
end

when "update"
puts "Enter a movie title"
title = gets.chomp
    if movies[title.to_sym].nil?  
    puts "Error"
    else
    puts "Enter a rate"
rating = gets.chomp
movies[title.to_sym] = rating.to_i
end

when "display"
movies.each { |movie,rating| puts "#{movie}: #{rating}" }
end

when "delete"
puts "Enter a title to delete"
 title = gets.chomp
    if movies[title.to_sym].nil? 
    puts "No movie!"
    else
    movies.delete(title.to_sym)
    puts "#{title} has been deleted."
end


#2

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