Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby

Mark Shaw
Mark Shaw
10,449 Points

Extra Credit Try

def get_list

    hash = {name: [], quantity: []}
    cycle = "y"
    puts
    print "What is the name of your list?: "
    name = gets.chomp

    while cycle == "y"
        puts
        print "What is the name of the item?: "
        item = gets.chomp.to_s
        puts
        print "Quantity?: "
        quan = gets.chomp
        puts
        hash[:name].push(item)
        hash[:quantity].push(quan)
        puts
        puts "Add another item?: y/n   "
        puts
        add = gets.chomp.downcase

        case add
            when "y"
            cycle = "y"
            when "n"
            cycle = "n"

        end
    end
    puts
    puts
    puts
    puts
    puts "List Name: #{name}"
    puts "------------------------------------------"
     hash[:quantity].each do |y|
        $y = y
     end
     hash[:name].each do |x|
             puts
             print "     #{x}                        "
             puts $y
             puts
             puts "------------------------------------------"
             puts
     end
end

get_list