i am trying to understand classes how to create list within them and how to append to that list.
i guess i missed a basic understanding of appending somewhere. or something else.
but for instance i try to append to a list like this.
when i run this and enter "grape" to be the appended item , nothing gets returned..
i guess i missed a basic understanding of appending somewhere. or something else.
but for instance i try to append to a list like this.
when i run this and enter "grape" to be the appended item , nothing gets returned..
class Fruit:
fruit_list = []
def __init__(self,name):
self.name = name
def named(self):
print("{} is a fruit".format(self.name))
def append1(self):
inp = input("add a fruit: ")
if input == " ":
self.fruit_list.append(inp)
return
self.fruit_list
apple = Fruit('apple')
apple.append1()
