Created
July 24, 2021 03:47
-
-
Save oiojin831/fcc83b67fcbd944b316309d769712122 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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