7/13 Oops, try again. It looks like you aren't printing each colon-separated key-value pair on its own line. Check the hint if you need help!


#1

secret_identities = {
"The Batman" => "Bruce Wayne",
"Superman" => "Clark Kent",
"Wonder Woman" => "Diana Prince",
"Freakazoid" => "Dexter Douglas"
}

secret_identities.each do |x,y|
puts y + ": " + x
end

Output:
Bruce Wayne: The Batman
Clark Kent: Superman
Diana Prince: Wonder Woman
Dexter Douglas: Freakazoid
{"The Batman"=>"Bruce Wayne", "Superman"=>"Clark Kent", "Wonder Woman"=>"Diana Prince", "Freakazoid"=>"Dexter Douglas"}


#2

That's because you output value: key and not key: value


#3

I have the same problem, but my output looks correct:

Secret_identities = {
"The Batman" => "Bruce Wayne",
"Superman" => "Clark Kent",
"Wonder Woman" => "Diana Prince",
"Freakazoid" => "Dexter Douglas"
}

secret_identities.each {|hero, person| puts "#{hero}: #{person}"}

Output:

The Batman: Bruce Wayne
Superman: Clark Kent
Wonder Woman: Diana Prince
Freakazoid: Dexter Douglas
{"The Batman"=>"Bruce Wayne", "Superman"=>"Clark Kent", "Wonder Woman"=>"Diana Prince", "Freakazoid"=>"Dexter Douglas"}


#4

Seems like you're using a hash that doesn't exist:

Secret_identities = {

vs

secret_identities.each

#6

i tried it like this and had the same problem

secret_identities.each do |x, y|
puts "#{x} : #{y}"
end

solved it be removing that extra space after the #{x}
puts "#{x}: #{y}"


#7

This worked for me, thanks heaps!