The requirements for the codes are as below:
Create a class called Burrito
. This burrito should have:
An attribute (
is_california
) is a boolean that indicates if the burrito is a California burrito (in other words, if it has fries in it!).An instance-specific attribute, (contents) is a list of contents in the burrito.
A method, (
add_fries
). If there were not already fries in the contents list, this method should add fries to the list of contents and updateis_california
to be true.
and my codes are below:
class Burrito():
def is_california(self):
contents = []
if 'fries' in contents:
is_california = True
if 'fries' not in contents:
is_california = False
def __init__(self,contents = []):
self.contents = contents
def add_fries(self):
if 'fries' not in contents:
contents.append('fries')
It does not work when I try to test the add_fries()
, is there any improvements to be made? Thanks!