5. Iterating over the Array


#1



https://www.codecademy.com/courses/ruby-beginner-en-693PD/0/5?curriculum_id=5059f8619189a5000201fbcb#


I do not understand what is wrong in mi=y code !
"It looks like you haven't added any key-value pairs to the frequencies hash."


puts "please write your text"
text = gets.chomp
words = text.split(" ")

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


#2

what do you enter when prompted by chomp? the only way i can get your error with your code is by not typing any text and pressing enter immediately. Enter some text when prompted


#3

Thanks stetim94, it worked great!


#4

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