Creating secure passwords is essential in today’s digital world. Whether you are building a login system or simply want to generate strong passwords for personal use, knowing how to automate password creation using Python is extremely valuable.
In this tutorial, we will break down a simple yet powerful Python Password Generator that uses letters, numbers, and symbols to create a randomized, secure password.
Why Build a Password Generator?

Weak passwords are the easiest target for hackers. A strong password must include:
- Uppercase and lowercase letters
- Numbers
- Special characters
- A random order
The Python script below covers all these requirements. Let’s explore how it works.
Complete Python Password Generator Code
import random
letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
'w', 'x', 'y', 'z',
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V',
'W', 'X', 'Y', 'Z']
numbers = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
symbols = ['!', '#', '$', '%', '&', '(', ')', '*', '+']
p_l = int(input("How many letters you want in your password?\n"))
p_n = int(input("How many numbers you want in your password?\n"))
p_s = int(input("How many symbols you want in your password?\n"))
password = []
for _ in range(p_l):
password.append(random.choice(letters))
for _ in range(p_n):
password.append(random.choice(numbers))
for _ in range(p_s):
password.append(random.choice(symbols))
random.shuffle(password)
shuffl_password = ""
for new_p in password:
shuffl_password = shuffl_password + new_p
print(f"Your password is: {shuffl_password}")
Step-by-Step Explanation
1. Importing the Random Module
import random
The random module allows us to randomly pick characters and shuffle them, ensuring every password is unpredictable.
2. Creating Lists of Characters
You created three lists:
letters→ A–Z and a–znumbers→ Digits 0–9symbols→ Special characters (!, #, %, &, etc.)
These lists act as a pool from which Python will pick characters.
3. Taking User Input
p_l = int(input("How many letters you want in your password?\n"))
p_n = int(input("How many numbers you want in your password?\n"))
p_s = int(input("How many symbols you want in your password?\n"))
The user decides how long the password should be and how many types of characters it must include.
4. Adding Random Characters to the Password
The script uses three loops:
for _ in range(p_l):
password.append(random.choice(letters))
This loop selects random letters and appends them to the password list.
The same logic is used for numbers and symbols.
5. Shuffling to Increase Randomness
random.shuffle(password)
This ensures the final password is not predictable—for example, letters first, then numbers. Everything gets mixed.
6. Joining the Final Password
shuffl_password = ""
for new_p in password:
shuffl_password = shuffl_password + new_p
The characters stored in the list are combined into a single string, creating your final password.
Final Output
Your password is: W9$k3P&f2+
Every time you run the program, you get a brand-new, highly secure password.
Conclusion
This Python Password Generator is a simple yet powerful project for beginners. You learned how to work with lists, loops, random modules, and string manipulation. You can expand this program further by:
- Adding password length validation
- Allowing automatic password strength rating
- Saving passwords securely using hashing
Python makes such tasks both fun and practical.
If you’re excited to continue your Python learning journey, there’s a great next step waiting for you. After experimenting with this password generator, you can dive into a hands-on tutorial that shows how to scrape movie transcripts automatically using Python and BeautifulSoup. It’s practical, beginner-friendly, and helps you understand how real-world data extraction works.

Do you love gambling? jwin7 casino Online is safe and convenient. We offer a wide selection of games, modern slots, a live casino, fast deposits and withdrawals, clear terms, and a stable website.
Playing at the casino? 8mbets Play online for real money. We offer a wide selection of slots, live dealers, fast payments, easy login, and exciting offers for new and returning players.
Looking for a casino? 8mbets bd Slots, table games, and live casino all in one place. Quick login, convenient registration, modern providers, stable payouts, and comfortable player conditions.
High-trust source https://buyverifiedaccountsforads.com greets media buyers in its selection Facebook accounts. If you need buy Facebook accounts for ads, the main point is usually not “just access”, but about passing checks reliably: confident spend, green status indicators in the dashboard and warmed-up Fan Pages. We’ve put together a practical checklist, so you can quickly see what fits your offers before paying.Topic navigation: account types (aged, auto-reg, PVA). Important: buying is only the entry point. After that, results depend on your launch process: how payments are added, how you share assets and permissions safely, how you react to policy notices and how you scale campaigns. Key advantage of this shop — is having a curated FB knowledge base, where we’ve written workable playbooks for account preparation. Our team can guide, how exactly to with minimal risk add a payment method, so you avoid common issues and scale with fewer resets. Join our community, learn educational ban breakdowns, build a system and ultimately raise efficiency with our assets without delays. Important: use assets lawfully and always with Meta policies in mind.
Ranking wyplacalnych https://masterszewc.pl kasyn online z szybkimi wyplatami. Analiza wiarygodnosci finansowej, licencji, limitow i czasu wyplat. Lista kasyn, ktorym gracze ufaja w latach 2025–2026.
PayID casinos https://payid-online-casinos.com play online quickly and securely. Instant deposits and withdrawals, convenient payments, licensed sites, popular slots, and live games. A selection of reliable casinos with up-to-date terms.
Проблемы с зубами? стоматология: диагностика, лечение кариеса, отбеливание, импланты и ортопедия. Индивидуальный подход, безопасные материалы, точные технологии и забота о здоровье зубов и дёсен.
Kasyna online https://verde-kasyno-online.pl graj z bonusami w 2026 roku. Aktualne oferty, szybkie logowanie i latwa rejestracja, popularne sloty i gry stolowe. Przeglad warunkow, metod wplat i wyplat dla komfortowej gry online.
The best independent casinos https://independent-casino.uk with fair terms, fast payouts, and transparent licensing. A review of trusted platforms without major holdings, offering unique bonuses, popular slots, and convenient deposit methods.
Мультимедийный интегратор itec интеграция мультимедийных систем под ключ для офисов и объектов. Проектирование, поставка, монтаж и настройка аудио-видео, видеостен, LED, переговорных и конференц-залов. Гарантия и сервис.
Нужны блины и диски? тренировочные блины для штанги широкий выбор весов, надежные материалы, точная калибровка. Отличное решение для силовых тренировок, кроссфита и профессиональных спортзалов.
Мультимедийный интегратор айтек интеграция мультимедийных систем под ключ для офисов и объектов. Проектирование, поставка, монтаж и настройка аудио-видео, видеостен, LED, переговорных и конференц-залов. Гарантия и сервис.
Zin in een casino? https://online-casinos-ideal.com Populaire gokkasten, roulette, blackjack en live dealers. Bonussen, toernooien, promoties en snelle uitbetalingen. Speel vanaf je telefoon of pc – altijd en overal.
Letar du efter ett casino? https://casino-utan-omsattningskrav.se Rattvisa bonusar, licens, snabba utbetalningar och transparenta villkor. Vi jamfor palitlighet, spel och betalningsmetoder for att hjalpa dig valja en saker plattform.
Лучшие книги от knizhka-malishka.ru – откройте для своего малыша мир увлекательных сказок и ярких историй! Здесь собраны лучшие издания для детей разного возраста, которые подарят радость чтения всей семье. Читайте книги онлайн удобно и выгодно!