Key value error in "Iterating over the Hash" (7/8)

ruby

#1

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

Code:

puts "Gimme a statement: "
text = gets.chomp
words = text.split(" ")
frequencies = Hash.new(0)

words.each do |x|
frequencies[x] += 1
end

frequencies = frequencies.sort_by {|word, count| count}
frequencies.reverse!

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

#2

Your code worked for me on the first try on this exercise. Try resetting the code. I gave two inputs - one a t e r the other a t t e r - both worked.


#3

Didn't work for me after resetting the code.


#4

Can you paste a screenshot - in which your code, the console and the error you get are clearly visible? Thanks!


#5

Didn't work for me either. I've been trying to do that exercise for a long time now.