Determine whether a number is available in the list

In this python if else program, we will determine whether a given number is available in the list.

The most convenient way to check whether the list contains the element is using the in operator.

Steps to solve the program
  1. Take a list of a random numbers of your choices.
  2. Take a number as input through the user.
  3. Using if-else statement check whether the input number is available in the given list or not.
  4. Print the respective output.
				
					list1 = [22,33,49,34,65,67,12,25]
num = int(input("Enter a number: "))

if num in list1:
    print(f"{num} is available in the list")
else:
    print(f"{num} is not available in the list")
				
			

Output :

				
					Enter a number: 65
65 is available in the list
				
			

Related Articles

describe the interview process.

find the largest number among three numbers.

Leave a Comment