7/8. Iterating over the hash


Here's my code.

puts "Text:"
text = gets.chomp

words = text.split(" ")

frequencies = Hash.new(0)
words.each { |element| frequencies[element] += 1 }

frequencies = frequencies.sort_by {|a, b| b}

frequencies.each do |word, frequency|
puts word + " " + frequency.to_s

I keep getting the error: 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!


Hi try to refresh the page.


Still came up with the same error message.


Hi ran you code and it's woks .
When you save & submit the code you should write something in the console and then click on Enter


Thank you so much it worked!