FAQ: A Night at the Movies - Update

This community-built FAQ covers the “Update” exercise from the lesson “A Night at the Movies”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Learn Ruby

FAQs on the exercise Update

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

Hi,

I think there is something wrong with the whole lesson. I always have an Error msg doesn’t matter how many times I complete the exercise. But when I click on “give me the answers” it puts the same (and I mean it the same) line of code the I just put in 2 seconds ago as my completion. S it looks like the only answer is good that the “Solution” button gives. I don’t get it and it’s kinda frustrating.

10 Likes

I have exactly the same issue :’(

Are you testing the correct part of the program each time? To clarify, are you testing the ‘delete’ part of your program on activity nine of the exercise and not the add, update or display portion?

Ohh sorry for the late reply, I got through on this and I don’t remember what exactly how that code was.

Hi,

in this exercise, if have set up my hash with strings instead of symbols to begin with (because the movie names that I was thinking of had spaces in their names and I wasn’t sure how to turn them into a symlbol syntax)

so I have coded something like this :

movies = [“Titanic” => 3 , “Lord of wars” => 4 ]

problem is, when I want to update one of the pairs of this hash, it doesn’t update it but it adds a new pair! (which is normal)

if I code
movies[“Titanic”.to_sym] = 1

I will end up with this new hash:

movies = [“Titanic” => 3 , “Lord of wars” => 4 , “Titanic” => 1]

So my question is how can you turn a hash made out of strings into a hash made out of symbols?

Thanks

image

I can´t understand why i have the “This movie is not on the list…” when try to update an existing movie from my list… Could somebodey help me? =/

So… I changed the if condition from
if movies[title.to_sym].nil? to
if movies[title].nil?

and it worked… but i still can´t understand why it worked now… hehehe

hi, i dont undestand how ruby reconize the varialbe title , when its decalre?
movies = {

StarWars: 4.8,

Divergent: 4.7

}

puts "What would you like to do? "

choice = gets.chomp

case choice

when “add”

puts "What movie would you like to add? "

title = gets.chomp

if movies[title.to_sym].nil?

puts "What rating does the movie have? "

rating = gets.chomp

movies[title.to_sym] = rating.to_i

else

puts "That movie already exists! Its rating is #{movies[title.to_sym]}."

end

when “update”

puts "What movie would you like to update? "

title = gets.chomp

if movies[title.to_sym].nil?

puts "That movie does not exist."

else

puts "What is the 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

So it looks like changes to the database hash are not saved each time you “run” the program. So you will have to use the key: value pairs you already defined at the top of your code to test your program.

Hi, I am having this problem and I cant work out how to select a specific section of Code to run instead of the whole thing.
It is prompting me to select the correct section but doesn’t say how to do it.

TIA

Hi, can any one help with this issue?

I am having the same problem as some people above. Every time I run my code I’m being prompted that i need to select the right section to run, e.g. “Update” section, but I don’t know how to select a specific section of code to run, it is trying to run it all at once every time.

TIA for any help.

Can you share a screenshot or copy/paste of the code that you have written?
There is no way to just run a specific section. In a series of exercises, we are gradually changing parts of the program. The whole program will run in every exercise.
By looking at your screenshot or copy/pasted code, we can better spot any issues or mistakes in following the instructions for the exercise.

hi, thanks for your reply.

this is the code:

the message that kept popping up was along the lines of "make sure you are selecting ‘delete’ " (which was to test that coding task. When I went in to “get solution” my code matched up fine, with slight differences where differences are allowed.

The problem with this exercise is that the gets method times out too quickly. If you type something at the prompt immediately after running (click there, then type and enter, quickly) you may get a chance to see the code run. Otherwise, bypass the input phase and manually code the input values. That way you can see the code run.

1 Like

Thank you for this. I’ll go back and have a play around with it!

1 Like

Not sure if this will help anyone else, but I was having trouble with this entire exercise too.
Turns out my browser window was timing out or just not updating with my code.

I tried refreshing the window and it cleared up a lot of the issues.
I didn’t get the “lost connection” message and my WiFi was strong, but for whatever reason, the window itself seems to time out, not just the code.