Issues with iterating over hashes


#1

https://www.codecademy.com/en/courses/ruby-beginner-en-F3loB/2/4?curriculum_id=5059f8619189a5000201fbcb#

I cannot understand how this is wrong. I have looked through other peoples posts on this and, as far as I can see, I don't have anything that has been addressed in another thread. Please help.

This is the error it gives me:

undefined local variable or method `price' for #

secret_identities = {
  "The Batman" => "Bruce Wayne",
  "Superman" => "Clark Kent",
  "Wonder Woman" => "Diana Prince",
  "Freakazoid" => "Dexter Douglas"
}
  
secret_identities.each do |hero, name|
    puts "#{hero} : #{name}"
end

#2

Can I see the exact code you used?
That backtrace makes it seem as if you have a variable named price in your code.
Price is used as a variable in the example for this lesson.


#3

I got it thank you, I was also having trouble because of the space with the colon.


#4

can you share your code?


#5

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