class MyRouter(object):
"This is a class that defines the aspects of a router"
def _init_(self, routername, model, serialno, ios):
self.routername = routername
self.model = model
self.serialno = serialno
self.ios = ios
def print_router(self, manuf_date):
print("The router name is: ", self.routername)
print("The router model is: ", self.model)
print("The serial number of: ", self.serialno)
print("The IOS version is: ", self.ios)
print("The model and date combined: ", self.model + manuf_date)
router1 = MyRouter("h1", "starhub", "123", "155")
print(router1)
Hi , when i am trying to print out router 1 , it returns an error message below :
Error:
Traceback (most recent call last):
File "C:/Users/teoho/PycharmProjects/untitled4/try1.py", line 1, in <module>
class MyRouter(object):
File "C:/Users/teoho/PycharmProjects/untitled4/try1.py", line 16, in MyRouter
router1 = MyRouter("h1", "starhub", "123", "155")
NameError: name 'MyRouter' is not defined
Why is that so ? Many thanks in advance.