136k views
5 votes
2. Use the correct membership operator to check if "banana" is not present in the fruits object

fruits = ["mango", "orange") if
"banana"
fruits:
print("Yes, apple is a fruit!")​

1 Answer

3 votes

Answer:

if not "banana" in fruits:

Step-by-step explanation:

Given the code segment

Required

Fill in the missing blank

Literally, membership operators are used to check the membership of an item in lists, tuples, strings, etc.

The given code segment defines a list named fruits with two items.

To check if "banana" is not in fruit, we make use of the following statement:

if not "banana" in fruits:

Which means if banana is not in fruit

Having done that, the complete program would be:

fruits = ["mango", "orange"]

if not "banana" in fruits:

print("Yes, apple is a fruit!")

User Ingo Karkat
by
5.4k points