这是一个程序,我想把它转换成一行:
def fix_machine(debris, product):
i=0
while(i<len(product)):
if(debris.find(product[i]) == -1):
return "Give me something that's not useless next time."
break
i = i + 1
return product
答案 0 :(得分:0)
debris = 'widget_z'
product = ['widget_a', 'widget_b', 'widget_c', 'widget_d']
if debris not in product: print("Give me something that's not useless next time.")
答案 1 :(得分:0)
更好地解释下次debris
和product
的内容,但我认为你想要这个:
def fix_machine(debris, product):
if set(product) <= set(debris):
return product
else:
return "Give me something that's not useless next time."
我认为debris
和product
现在都是字符串。