4. Prompting: Redux!


#1

I'm stuck in this exercise.
It's giving me this message: "Oops, try again. It looks like you didn't add to the movies hash!"
Can someone help me with please?

movies = { "fargo" => 4 }

puts "which movie do you want?"
choice = gets.chomp

case choice
when "add"
puts "what is the title of the movie?"
title = gets.chomp
puts "what is the rating of the movie?"
rating = gets.chomp

movies[title] = rating
puts "the pair #{title} and #{rating} was added."

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

`


#2

'''
movies = {
fightclub: 5
}

puts "Would you like to 'add', 'update', 'display' or 'delete'?"
choice = gets.chomp

case choice
when "add"
puts "What movie title would you like to add?"
title = gets.chomp
puts "What is this movies rating?"
rating = gets.chomp
movies[title] = rating
puts "#{title} has been added with a rating of #{rating}"

when "update"
puts "Updated!"
when "display"
puts "Movies!"
when "delete"
puts "Deleted!"
else
puts "Error!"
end
'''

Your code looks pretty much the same as mine, which passed


#3

Thanks for your help.
I found out that I was just inputting the wrong value.


#4

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