{}
run-icon
main.py
import random # Function to generate a username based on the provided first and last name. def username_generate(first_name, last_name): # Generate a ramdom two-digit number string random_num = f"{random.randint(0,9)){{random.randint(0,9)}" # Check if last name is less than 4 characters if len(last_name) < 4: username = first_name[0] + last_name + last_name + random_num #Concatenate last name twice else: username = first_name[0] + last_name[:4] + random num # Use first 4 characters of last name # Convert the username to lowercase and return it return username.lower() # Function to validate the user's password against minimum length, character type requirements, and not including the username. def password_check(user_password): # Check if password length is less than 8 characters if len(user_password) < 8: print("password must be last 8 characters long!\n") return false # password fails length requirement #Check if password includes any of the specified symbols elif user_password.find("!") == -1 and user_password.find ("$") == -1 and user_password.find("@") == -1: print("password is missing symbol such as '@', '!', or '$'!\n") return False # Password fails symbol requirment # Check if password includes the username elif username in user_password: print("Password cannot contain the username!\n") return False # Password fails username requirment
Output