【发布时间】:2018-08-07 07:10:30
【问题描述】:
我是Python 的新手,并决定在TestDome 进行一些练习。以下是来自该网站的easy question 的代码,但由于它没有按应有的方式打印结果,因此得分为零。
class IceCreamMachine:
all={}
def __init__(self, ingredients, toppings):
self.ingredients = ingredients
self.toppings = toppings
def scoops(self):
for i in range(0,len(self.ingredients)):
for j in range(0,len(self.toppings)):
print ([self.ingredients[i],self.toppings[j]])
machine = IceCreamMachine(["vanilla", "chocolate"], ["chocolate sauce"])
print(machine.scoops()) #should print[['vanilla', 'chocolate sauce'], ['chocolate', 'chocolate sauce']]
任何人都可以提示如何解决它吗?
【问题讨论】:
标签: python collections