ImportError: cannot import name 'Tab' from 'bar_tab'

I'm learning python. Trying to do a simple tutorial from youtube. Here is the code:

class Tab:

menu = {
    'wine': 5,
    'beer': 3,
    'soft_drink': 2,
    'chicken': 10,
    'beef': 15,
    'veggie':12,
    'dessert': 6
}

def __init__(self): 
    self.total = 0
    self.items = []

def add(self, item):
    self.items.append(item)
    self.total += self.menu[item] 

def print_bill(self, tax, service):
    tax = (tax/100)*self.total
    service = (service/100)*self.total 
    total = self.total + tax + service

    for item in self.items: 
        print(f'{item} ${self.menu[item]}')

    print(f'{"Total"} ${total:.2f}')

and using 'Cmder' from the website http://cmder.net, I'm writing this and getting this error:

'>>>from bar_tab import tab

Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: cannot import name 'tab' from 'bar_tab ' (C:\Users...\bar_tab.py)

I don't understand what I'm doing wrong. Just trying to import this class from module. Can someone please help?

spidermunky's avatar
11
spidermunky
asked 2019-02-18 01:36:32 -0500
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments