Projects in Python related to user account creation

Projects in Python related to user account creation


7 min read


This post is a part of #BlogchatterA2Z Challenge 2023.

Are you looking for Python projects related to user account creation? Check out these coding challenges that can help you improve your skills in this area. From creating user accounts and validating passwords to generating usernames and passwords, these projects cover a range of topics that can enhance your understanding of Python and its applications. Whether you're a beginner or an experienced programmer, these projects can provide you with valuable insights and hands-on experience. Read on to learn more about each project and how to get started.


I got a wonderful book titled 50 Days of Python: A Challenge A Day from Benjamin Bennett Alexander; a gift from my Twitter connection. I completed the book in 30 days; not continuously though. I will present some of the problems, taken from the book, related to user account creation, that can be used in projects.


1.Username Generator from User's Email

Day 6: Write a function called user_name that generates a username from the user’s email. The code should ask the user to input an email, and the code should return everything before the @ sign as their user name. For example, if someone enters, the code should return ben as their username.

#Day6 Username Generator

def user_name():
    email = input("Enter your email ID \n")
    print("Entered email ID : ",email)
    indexAt = email.index('@')
    username = email[:indexAt]
    print("The username extracted from emailID =",username)


Output :

Enter your email ID 
Entered email ID :
The username extracted from emailID = starcodes

2.Hiding password

Day 10: Write a function called hide_password that takes no parameters. The function takes an input (a password) from a user and returns a hidden password. For example, if the user enters "hello" as a password, the function should return "****" as a password and tell the user that the password is 4 characters long.

#Day10 - Hide my password

def hide_password():
    password = input("Enter your password \n")
    #print("Password = ",password)
    len_password = len(password)
    #print("Length of password = ",len_password)
    str_show = ''
    for ii in range(0,len_password):
        str_show = str_show +'*'
    print("The password is " , len_password , "characters long.")



Enter your password 
The password is  6 characters long.

3.Username Generator

Day 17: Write a function called user_name, that creates a username for the user. The function should ask a user to input their name. The function should then reverse the name and attach a randomly issued number between 0 and 9 at the end of the name. The function should return the username.

#Day17 - Username Generator
import random

def user_name():
    name = input("Enter you name: \n")
    print("Entered name:",name)
    name_rev = name[::-1]
    rand_num = random.randrange(9)
    user_name_gen = name_rev+str(rand_num)
    print("Username generated =",user_name_gen) 



Enter you name: 
Entered name: Sherlock
Username generated = kcolrehS7

4.User creation

Day 31 Extra Challenge: Write a function called create_user. This function asks the user to enter their name, age, and password. The function saves this information in a dictionary. For example, if the user enters Peter as his name, 18 as his age, and "love" as his password, the function should save the information as: {"name": "Peter", "age": "18", "password": "love"} Once the information is saved, the function should print to the user, "User saved. Please login" .

The function should then ask the user to re-enter their name and password. If the name and password match what is saved in the dictionary, the function should return "Logged in successfully." If the name and password do not match what is saved in the dictionary, the function should print "Wrong password or user name, please try again". The function should keep running until the user enters the correct logging details.

#Day31 EC - Create User
def create_user():
    dict_user = {}
    name = input("Enter the name \n")
    age = int(input("Enter age: \n"))
    password = input("Enter password \n")
    usr_input = ["name","age","password"]
    dict_user["name"] = name
    dict_user["age"] = age
    dict_user["password"] = password
    print("User Saved. Please login.")
    while True:
        name1 = input("Reenter your name \n")
        password1 = input("Reenter your password \n")

        if name == name1 and password == password1:
            print("Logged in successfully!")
            print("Wrong password and username. Please try again.")



5.Password Validator

Day 32: Write a function called password_validator. The function asks the user to enter a password. A valid password should have at least one uppercase letter, one lowercase letter, and one number. It should not be less than 8 characters long. When the user enters a password, the function should check if the password is valid. If the password is valid, the function should return the valid password. If the password is not valid, the function should inform the user of the errors in the password and prompt the user to enter another password. The code should only stop once the user enters a valid password. (use while loop).

def password_validator():
    errors = []
    while True:
        password = input('Enter your password: ')
        if not any(i.isupper() for i in password):
            errors.append("Please add at least one "
                        "capital letter to your password")
        elif not any(i.islower() for i in password):
            errors.append("Please add at least one "
                        "small letter to your password")
        elif not any(i.isdigit() for i in password):
            errors.append('Please add at least one '
                        'number to your password')
        elif len(password) < 8:
            errors.append("Your password is less "
                        "than 8 characters")
        if len(errors) > 0:
            print('Check the following errors:')
            del errors[0:]
            return f'Your password is {password}'



  • 6.Valid Email

    Day 32 Extra Challenge:

    emails = ['', '', '', '']

    Write a function called email_validator that takes a list of emails and checks if the emails are valid. Only valid emails are returned by the function. A valid email address will have the following: the @ symbol (if the @ sign is at the beginning of the name, the email is invalid). If there is more than one @ sign, the email is invalid. All valid emails must end with a dot com (.com); otherwise, the email is invalid. For example, the list of emails above should output the following as valid emails: ['', ''] If no emails in the list are valid, the function should return "all emails are invalid."

          #Day32 - EC
          def email_validator(emails):
              valid_email = []
              for ii in emails:
                  if ii[0]!='@'and ii.count('@')==1 and ii[-4:]=='.com':
              return valid_email
          num = int(input("Enter the length for email's list: \n"))
          list_emails = []
          for ii in range(0,num):
              entry = input("Enter emails one by one \n")
          print("Entered emails = ",list_emails)
          res = email_validator(list_emails)
          print("Valid emails are = ",res)


    7.Password Generator

    Day 39: Create a function called generate_password that generates any length of password for the user. The password should have a random mix of uppercase letters, lowercase letters, numbers, and punctuation symbols. The function should ask the user how strong they want the password to be. The user should pick from weak, strong, or very strong. If the user picks "weak," the function should generate a 5-character long password. If the user picks "strong," generate an 8-character password, and if they pick "very strong," generate a 12-character password.

          #Day39 - Generate password
          import string
          import random
          def password_generator():
          # string module constants
              a = string.ascii_letters + \
                  string.digits + string.punctuation
              password1 =[]
              length = input("Pick your password length "
              "a,b or c: \na. weak \nb.strong \nc."
              "Very strong...: ")
              if length == 'a':
                  length = 5
              elif length == 'b':
                  length = 8
              elif length == 'c':
                  length = 12
              for i in range(length):
                  password = str(random.choice(a))
              return 'You password is', ''.join(password1)


đź’ˇFinal Note

Practice makes a man perfect.

To master any skill, one requires to apply the theories to practices and coding is no exception. From unlimited benefits from Twitter, this book came to me as a priceless gift. As I had experience coding in Python before, the problems from this book act as a source of revision. I revisited the concepts that I had learned and picked up tips and tricks along the way. I would recommend this book to beginners.

Did you find this article valuable?

Support Swati Sarangi by becoming a sponsor. Any amount is appreciated!