In this python if else program, we will validate user_id in the list of user_ids. Take a user id to validate user_id.
Steps to solve the program
- Take a list of user ids and take a user id as input through the user.
- Check whether the input id is in the list of user ids or not using an if-else statement.
- Print the respective output.
# List of user ids
id_list = [1,2,3,5,6,7,8]
# Take user id as input through the user
id_ = int(input("Enter ID number: "))
# Check whether input id is in list of ids
if id_ in id_list:
# Print output
print("Valid ID")
else:
# Print output
print("Invalid ID")
Output :
Enter ID number: 5
Valid ID
Related Articles
Python program to print a square or cube if the given number is divided by 2 or 3 respectively.
Python program to describe the interview process.
Python program to determine whether a given number is available in the list of numbers or not.
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.