Issues with iterating over hashes


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


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.


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


can you share your code?


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