Kingsley Bawuah Kingsley Bawuah - 2 months ago 5
Python Question

NameError: name 'name' is not defined

Currently working through Python Crash course and this example is giving me trouble

class Restaurant():
def __init__(self, restaurant_name, cuisine_type):
""" initializing name and cuisine attributes"""
self.restaurant_name = name
self.cuisine_type = c_type

def greeting(self):
"""simulate greetting with restaurant info..."""
print( + " is a " + self.c_type.title()
+ " type of restaurant.")

def open_or_nah(self):
""" wheteher or not the restaurant is open in this case they will be always"""
print( + " is open af")

china_king = Restaurant('china king', 'chinese')

the console keeps giving me the error

Traceback (most recent call last):
File "python", line 16, in <module>
File "python", line 4, in __init__
NameError: name 'name' is not defined

I've searched around for the reason as to what is causing this but i can't figure it out. What's wrong?


Looks like a small mistake, just modify it in your __init__ = restaurant_name