Skip to content

Instantly share code, notes, and snippets.

@oiojin831
Created July 24, 2021 03:47
Show Gist options
  • Save oiojin831/fcc83b67fcbd944b316309d769712122 to your computer and use it in GitHub Desktop.
Save oiojin831/fcc83b67fcbd944b316309d769712122 to your computer and use it in GitHub Desktop.
class Food:
def __init__(self, name, color):
self.name = name
self.color = color
class FoodList:
def __init__(self):
self.foods = []
def add_food(self, name, color):
new_food = Food(name, color)
self.foods.append(new_food)
def show_foods(self):
for food in self.foods:
print(food.name)
my_list = FoodList()
my_list.add_food("pizza", "yellow")
my_list.add_food("kimbob", "black")
my_list.show_foods()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment