Q:

Trying to return relevant information from a list of lists based on user input

I'm very new to Python, and I just can't get the hang of functions yet. I have a list of lists that has 3 products, their inventory, and their price.
products = [['milk', 'eggs','bread'], [10,15,20], [3.50, 2.00, 2.50]]

I want to create a function so that the user input can choose which product they want information about, and if they want the inventory number, the price, or both. 
def return_information():

Does this require a ton of nested if statements or am I overthinking it in that way?
Should my user input statements take place within this first function or do they belong in a main function where I execute the whole program?

A:

Try this:
products = [['milk', 'eggs','bread'], [10,15,20], [3.5, 2.00, 2.5]]
total_number_items = sum(products[1])
min_num = min(products[1])
max_num = max(products[1])
average_price = sum(products[2]) / len(products[2])

def generate_overall_stats():
    return total_number_items
    return max_num
    return min_num

def return_information():  
    inquiry = input('Which product would you like information about?')
    if inquiry in products[0]:
        inquiry_2 = input('Would you like quantity, price, or both?')
        if inquiry_2 == 'both':
            print([i[products[0].index(inquiry)] for i in products[1:]])
        if inquiry_2 == 'price':
            print([i[products[0].index(inquiry)] for i in products[1]])
        if inquiry_2 == 'quantity':
            print([i[products[0].index(inquiry)] for i in products[2]])
        if inquiry_2 not in ['both','price','quantity']:
            print('Info does not exist')
    else:
        print('product does not exist')

def main():
    run = True
    while run:
        print('1.Generate overall statistics')
        print('''2.Retrieve information (quantity or price) for a given 
product')''')
        UserOp = int(input('Select an operation by entering its number: '))
        if UserOp == 1:
            print(generate_overall_stats())
        if UserOp == 2: 
            return_information()    
        runCheck = input('Do you want to run another operation? ')
        if runCheck.lower() == 'no':
            run = False
            print('Goodbye')
main()

