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
- Take a list of a random numbers of your choices.
- Take a number as input through the user.
- Using if-else statement check whether the input number is available in the given list or not.
- 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
Python program to find the largest number among three numbers.
Python program to check any person eligible to vote or not
Python program to check whether any given number is a palindrome.
Python program to check if any given string is palindrome or not.
Python program to check whether the given number is positive or not.