Introduction to Python

in keyword

Just like with strings, you can use the built-in in keyword with lists to check if a list contains a given element. The in keyword returns a boolean value (True or False) depending on whether the element is found in the list.
Here’s an example of using the in keyword with a list:
fruits = ['apple', 'banana', 'orange', 'grape']

if 'apple' in fruits and 'banana' in fruits:
    print('We have both apples and bananas!')
In this example, we use the and operator to check if both apple and banana are in the fruits list. If both are present, the if statement is True, and the message We have both apples and bananas! is printed.


You are helping the famous “Four Ingredients” cafe write their order processing system. The first four lines of input list the ingredients of a menu item, while the next two lines list the ingredients that a customer is allergic to. Your task is to print Order accepted! if there are no allergens in the ingredients or Allergen alert! if a customer is allergic to one or more ingredients.
egg apple flour brown sugar apple strawberry
Allergen alert!
spinach feta egg short crust pastry peanut honey
Order accepted!


Time limit: 1 seconds

Memory limit: 512 MB

Output limit: 1 MB

To check your solution you need to sign in
Sign in to continue