shopping_cart = [['tooth paste', 'q-tips', 'milk],['milk', 'candy', 'apples'],['planner', 'pencils', 'q-tips']]
for x in shopping_cart: #this is the overall list
for i in shopping_cart: #This is the 3 inner lists?
if shopping_cart[0:2] != 'milk': # this should check for milk in list
shopping_cart.append('milk') # this should append milk to the end of the list if milk isnt in yet
shopping_cart = [['牙膏','q-tips,'牛奶',''milk','candy','apples],['planner','铅笔','q-tips]] ] for shopping_cart中的x:#这是shopping_cart中i的整体列表:#这是...
由于您没有提到预期的输出,我假设这就是您要寻找的。