Iterating Over the Hash - Create a Histogram


Link to the Lesson

Error Message:

Oops, try again. It looks like you aren't printing each key-value pair to the console correctly. Make sure to put a space between each key and value!

I'm having serious trouble with this lesson and have been stuck on it for around a week. I've tried almost everything I can think of: clearing the cache, changing browsers, editing the code a bit, and using other packs of code from this forum. None of them work. Thus, I am asking for desperately needed help in this section (mostly if my code works for other people).


puts "text"
text = gets.chomp

words = text.split
puts "more text"
frequencies =
words.each { |word| frequencies[word] += 1 }
frequencies = frequencies.sort_by do |a, b| b
frequencies.each do |word, frequency|
    puts word + " " + frequency.to_s
puts frequencies
puts frequencies["puppy"]


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