Python program to validate user_id in the list of user_ids.

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

  1. Take a list of user ids and take a user id as input through the user.
  2. Check whether the input id is in the list of user ids or not using an if-else statement.
  3. 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

check authentication with the given username and password.

print a square or cube if the given number is divided by 2 or 3 respectively.

Leave a Comment