7. Update - Oops, try again. Make sure to test your program by choosing 'update'


#1

Hey, I'm having a hard time passing this lesson,
my code seems to do what it is supposed to do, but the console still tells me this:
"Oops, try again. Make sure to test your program by choosing 'update'."

Even though I use update to test my code and it works as it should work - tells me if the movie I entered doesn't exist or when the movie exist, it updates the rating and tells me that the rating have been updated with the given value...

It seems like the console wants some kind of exact response in the end to tell me I suceeded, but I can't seem to find what it should be...

movies = {
    "Pulp Fiction" => 5,
    "Batman Begins" => 4.5,
    "Minions" => 3,
    "Life is life" => 2.5,
    "Suicide squad" => 1.5
    }

puts "What do you want to do? (add, update, display, delete)"

answer = gets.chomp

case answer

when "add"
    puts "Enter movie name:"
    title = gets.chomp
        if movies [title].nil? 
    puts "Enter your movie rating:"
    rating = gets.chomp
    movies [title.to_sym] = rating.to_i

    puts "Added to the list!"
     else puts "This movie already exists in the database!"
end
when "update"
    puts "Enter movie name:"
    title = gets.chomp
        if movies[title].nil?
            puts "This movie is not in the database!"
        else
    puts "Enter your movie rating:"
    rating = gets.chomp
    movies [title.to_sym] = rating.to_i
    puts "Movie #{title} was updated with the rating of #{rating}!"
end
when "display"
    puts "Movies!"
when "delete"
    puts "Deleted!"
else
    puts "Error!"
end

Thanks a lot for a response :slight_smile:


#2

Your code is correct and it passes the exercise.

Please try to:

  1. copy your code;
  2. click reset code;
  3. click save & submit code;
  4. paste your code back into the editor;
  5. click save & submit code again;
  6. choose update option and input movie data.

If this does not work please make a screenshot and post it here :slight_smile:


#3

Ouch, thanks and sorry about spamming the forum with such thing...
Reseting the code and pasting it back again didn't help, but what helped was refreshing the page and trying it reseting and pasting back again...
Now I feel stupid for not trying it on my own :disappointed:
I was simply trying to find some mistake in my code

So what, now I can finally continue :slight_smile: Thanks a lot! :+1:


#4

Ouch, thanks and sorry about spamming the forum with such thing...

You had the problem, you created a single discussion - that's not spamming :slight_smile:

Good luck with next exercises and you're welcome! :slight_smile:


#5

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