-2

I have this code:

tot_l_cap = 0
tot_r_cap = 0
tot_l_esp = 0
tot_r_esp = 0
tot_l_lat = 0
tot_r_lat = 0
tot_l_iced_c_ic = 0
tot_r_iced_c_ic = 0
tot_l_iced = 0
tot_r_iced = 0

print('Please enter all choices with the integer they are associated with.')


def coff_menu(): 
    print('-------------------------------------------------------------------------------------------------') 
    print('1. Cappuccino:       |Regular: $4.40         |Large: $4.95')
    print('-------------------------------------------------------------------------------------------------')
    print('2. Espresso:         |Regular: $3.60         |Large: $4.15')
    print('-------------------------------------------------------------------------------------------------')                
    print('3. Latte:            |Regular: $3.85         |Large: $4.40')
    print('-------------------------------------------------------------------------------------------------')
    print('4. Iced Coffee With ice-cream and cream:          |Regular: $4.40         |Large: $4.95')
    print('5. Iced Coffee Without:                           |Regular: $3.85         |Large: $4.40' )
    print('-------------------------------------------------------------------------------------------------')


def order():
    coff_menu()
    coff_type = int(input("What coffee would you like to order? "))
    coff_size = input('Would you like the size to be regular or large? ')
    quant_coff = int(input("How many would you like to order?  "))
    return coff_type, coff_size, quant_coff


def cap_order():
    if coff_type == '1':
        if coff_size == 'Large':
            price = 4.95 * quant_coff
            tot_l_cap += cost
        elif coff_size == 'Regular':
            price = 4.40 * quant_coff
            tot_r_cap += cost    
    return cost

I get errors that tell me that coff_type, coff_size and quant_coff are not defined within def cap_order. Why? How can I fix the problem?

Karl Knechtel
  • 62,466
  • 11
  • 102
  • 153
  • 3
    Are you sure you are using [tag:python-2.7]? Your `print()` seems to be more of a Python 3's `print()` function rather than Python 2's `print` keyword. – InSync Aug 10 '23 at 01:45
  • [ask] and [mre] – Julien Aug 10 '23 at 02:13
  • You need to learn about variable _scope_. Your coff_type, coff_size and quant_coff are local to `order` and are not accessible from `cap_order`. – Gino Mempin Aug 10 '23 at 04:10
  • First off, functions need to be called in order to do anything - they don't just run automatically, and there is nothing in the code you have shown that would actually use the `order` function. After fixing that, please see the linked duplicate. – Karl Knechtel Aug 10 '23 at 04:53

0 Answers0