-
-
Save stephengruppetta/2f83cd1aca627667bdf2b0cd301becc8 to your computer and use it in GitHub Desktop.
This file contains 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 VendingMachine: | |
def __init__(self): | |
self.items_on_sale = [] | |
def __getitem__(self, idx): | |
return self.items_on_sale[idx] | |
def add_items(self, items): | |
self.items_on_sale.extend(items) | |
hideous_machine = VendingMachine() | |
hideous_machine.add_items( | |
[ | |
"Hazelnut Chocolate", | |
"Dark Chocolate", | |
"Still Water", | |
"Sparkling Water", | |
] | |
) | |
print(hideous_machine[2]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment