Jun-15-2019, 07:47 AM
I'm getting a type error.
I want to write a subclass and add an attribute to it, then write a method to display the attribute and call the method.
So basically, I have a class Restaurant and I have a subclass IceCreamStand and I added an attribute flavors to the subclass and a method print_flavors to display the flavors, then I have to call the method.
The specific error I get is TypeError: __init__ takes 3 positional arguments but 4 were given.
Any help would be appreciated.
I want to write a subclass and add an attribute to it, then write a method to display the attribute and call the method.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
Class Restaurant (): def __init__( self , restaurant_name, cuisine_name): self .restaurant_name = restaurant_name self .cuisine_name = cuisine_name def describe_restaurant ( self ): print ( "This is " + self .restaurant name.title()) print ( self .cuisine_name.title() + " is the only cuisine right now" ) def open_restaurant( self ): print ( self .restaurant_name.title() + " is open for business " ) class IceCreamStand(Restaurant): def __init__( self , restaurant_name, cuisine_name): super ().__init__(restaurant_name, cuisine_name) self .flavors = flavors def print_flavors( self ): print ( self .flavors) IceCream = IceCreamStand( 'dominos' , 'pizza' , 'BBQ' ) IceCream.IceCreamStand.print_flavors() |
The specific error I get is TypeError: __init__ takes 3 positional arguments but 4 were given.
Any help would be appreciated.