Display error


I've got stuck on this exercise:


My code correctly displays all of the titles, but I still get this error:
"Oops, try again. It looks like your 'puts' doesn't include Scott Pilgrim vs The World: 3.9. "
While console is:
"- display
Scott Pilgrim vs The World: 3.9
Pulp Fiction: 3.5
{:"Scott Pilgrim vs The World"=>3.9, :"Pulp Fiction"=>3.5} "

movies = {
    :"Scott Pilgrim vs The World" => 3.9,
    :"Pulp Fiction" => 3.5,

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."

print "-"
choice = gets.chomp.downcase

case choice

when "add"
    puts "- What's the title?"
    print "-"
    title = gets.chomp.downcase
    puts "- Rate the movie. "
    print "-"
    rating = gets.chomp
    if movies[title.to_sym].nil?
        movies[title.to_sym] = rating.to_i
        puts "- Added!"
        puts "- Already in list. #{title} have #{movies[title]} rating"
when "update"
    puts "- What's the title?"
    print "-"
    title = gets.chomp.downcase
    if movies[title.to_sym].nil?
        puts "- Where is not such film, actially."
        puts "- What's new rating? "
        print "-"
        new_rating = gets.chomp
        movies[title.to_sym] = new_rating.to_i
        puts "- Updated!"
when 'display'
    movies.each do |movie, rating|
    puts "#{movie}: #{rating}"
when "delete"
    puts "Deleted!"
    puts "Error!"


Nvm, I've got rid of "print" before "choice = gets.chomp.downcase" and it worked.


For me, the issue seems to be fixed by changing the following line:

print "-"

I suspect because print doesn't add a new line after -, the interpreter might be getting confused. If you change the line to be puts "-" instead, it should work.

Sometimes being allowed to have a symbol or a string for hash keys can be confusing too.

In this case, because the hash keys are strings, the : isn't needed, so

:"Scott Pilgrim vs The World" => 3.9

can be simplified to

"Scott Pilgrim vs The World" => 3.9

Hopefully that helps, and you can move on!


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