Day 004 of the 100 Days of Python challenge creates passwords from user-selected quantities of letters, symbols, and numbers.

Project Overview

The program keeps three character lists: upper- and lowercase letters, symbols, and digits. It asks how many characters of each type the user wants, then builds a list of randomly selected characters.

The first two groups are placed into their requested positions, numbers are added after them, and random.shuffle() changes the order before the password is displayed. Shuffling prevents every password from following a predictable letters-then-symbols-then-numbers pattern.

for char in range(pwd_letters):
    password_chars.append(random.choice(letters))

random.shuffle(password_chars)
password = "".join(password_chars)

What This Project Teaches

Day 004 practices the random module, lists, for loops, indexing, list mutation, and joining strings. It also introduces a practical security idea: variety and unpredictable ordering make generated passwords less obvious.

For production password generation, secrets would be preferable to random, because it is designed for security-sensitive randomness. This challenge project is focused on learning Python fundamentals.

Running the Project

cd 100daysofpython/day004
python main.py

View the Day 004 source code on GitHub.