available_toppings = ['mushrooms','olives','green peppers','pepperoni','pineapple','extra cheese']

requested_toppings = ['mushrooms','french fries','extra cheese']

for requested_topping in requested_toppings: 
    if requested_topping in available_toppings:
        print('Adding '+ requested_topping + '.')
    else:
        print("Sorry, we don't have " + requested_topping +".")
print('\nfinished making your pizza!')

在列表里,我们遍历顾客点的配料列表。在for语句循环中,对顾客点的每个配料,都会检查它是否在供应的配料表里。如果在供应列表里有,则把它加入到披萨中,否则将运行else代码块