Generate Usernames with Python: A Simple Project for Beginners

Al-Junaed Islam
3 min readApr 3, 2023

--

Are you ready to put your Python knowledge to the test and build a useful tool? Follow this step-by-step instruction to create a User Name Generator.

Photo by Mark Stuckey on Unsplash

Python is a versatile and powerful programming language with many applications in the real world. In this post, we will walk through the creation of a User Name Generator using Python.

First, let’s take a look at the code:

print("Welcome To The User Name Generator by AJBrohi!\n")

name = input("Please Enter Your Nick Name or Last Name: ")
digit = input("Please Enter Last Two Digits of Your Birth Year: ")

username = name + str(digit)

print("Generating A Username For You...")
print("Your Username Is: "+ username+"\n")

This code is a simple yet effective way to generate unique usernames based on a user’s name and birth year. Here’s how it works step-by-step:

print("Welcome To The User Name Generator by AJBrohi!\n")

The program starts by printing a welcome message to the user.

name = input("Please Enter Your Nick Name or Last Name: ")
digit = input("Please Enter Last Two Digits of Your Birth Year: ")

Next, the program asks the user to enter their nickname or last name and the last two digits of their birth year.

username = name + str(digit)

The user’s input is then combined into a single string, which becomes their new username.

print("Generating A Username For You...")
print("Your Username Is: "+ username+"\n")

Finally, the program prints a message to let the user know that their username has been generated and displays the new username on the screen.

Output:

User Name Generator

This project is a great way for beginners to get started with Python programming. Here are some of the key features and Python concepts used in this code:

  • Input/output: The program takes user input using the input() function and outputs messages to the console using the print() function.
  • Variables: The program uses variables to store user input and to generate the new username.
  • String manipulation: The program uses string concatenation to combine the user’s input into a single string.
  • Type conversion: The input() function returns a string, so the program uses the str() function to convert the user's birth year digits to a string before concatenating it with their name.

Finally, this User Name Generator is a simple and enjoyable project that can assist beginners in learning fundamental Python concepts as well as methods. Try it out and see what creative usernames you can come up with!

--

--

No responses yet