Created
March 22, 2020 16:52
-
-
Save aliaramli/4a8319a47e342c6973ad152bd778228f to your computer and use it in GitHub Desktop.
Python data stucture simple array Ice Cream Machine
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 IceCreamMachine: | |
def __init__(self, ingredients, toppings): | |
self.ingredients = ingredients | |
self.toppings = toppings | |
def scoops(self): | |
final_scoops = [] | |
for ingredient in self.ingredients: | |
for topping in self.toppings: | |
final_scoops.append([ingredient,topping]) | |
if(final_scoops): | |
return final_scoops | |
else: | |
return [] | |
machine = IceCreamMachine(["vanilla", "chocolate"], ["chocolate sauce"]) | |
print(machine.scoops()) #should print[['vanilla', 'chocolate sauce'], ['chocolate', 'chocolate sauce']] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment