Gets.chomp into an Array

I have an assignment for class. I have to input each monthly bill for each month.
I begin with months = [“January”, “February”, …]
the user needs to input how much the bill was for each month
so then i put bill = gets.chomp

so it would be like
puts “Enter all the bills for each month”
bills = gets.chomp
user puts 123 234 345 456…
im stuck on getting each bill into an array
so it displays

I hope this makes sense :confused:

Have you tried << or push into array?

bills =
months.each do |m|
  print "#{m}: "
  input = gets.chomp.to_i
bills = gets.chomp

or if you want integers

bills =

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs