Need to create a Hash using user input in Ruby

The goal is to get the user to enter 3 separate numbers and have the script store those in a Hash, output the values, and then add all the numbers in the hash. The script I'm working on keeps erroring out, and I was hoping for some guidance on how to correct it.

# Declare an empty hash with the { } notation
entries = { }
# Request input N times
(1..3).each do |n|
puts "Enter number %d" % n
# Add this entry to the hash, convert it to an integer with to_i
entries[:"num#{n}"] = gets.chomp.to_i
end
# Add the numbers together and have a default of 0 in case the array
# is empty.
puts "the sum is %d" % entries.values.inject(0, :+)

Your original code was re-defining the userhash variable as an array with a hash in it. This new code organizes things into a single hash with multiple entries, though given how it's used, this isn't necessary. Instead you could do this: