How To Check If A Number Is Not In A List Python

Checking if a number is not in a list is a common task in Python programming. This tutorial will guide you through the steps of checking if a number is not in a list using Python.

Steps:

1. Define the list of numbers.

2. Use the not in operator to check if the number is not in the list.

This code will check if the number 6 is not in the list numbers. If it is not in the list, it will print “6 is not in the list”. If it is in the list, it will print “6 is in the list”.

3. Replace the number 6 with the number you want to check.

Replace [number] with the number you want to check.

Example:

Let’s check if the number 6 and 9 is not in the list numbers.

The output will be:

Output:

This output tells us that the number 6 and 9 is not in the list of numbers.

Conclusion:

Checking if a number is not in a list in Python is easy using the not in operator. Follow these steps to determine if a number is not in a list.