top of page
Search

Python Project

  • Writer: Chrissy
    Chrissy
  • 4 days ago
  • 1 min read

Updated: 3 days ago

Simple Password Generator.


Practicing what I learned while working with for loops and the random Python module.


https://github.com/ChrisLearningCode2/pwdgeneratorPHY/blob/main/README.md Its not doing what I wanted to do, so I am still learning. Will be off studying what I did incorrectly, and fix it. *fix was added down below

ree


After doing some more homework, I found my mistake!

The INT / INPUT were defined incorrectly to output what I was hoping the code would do.


The code had no syntax errors, but it did have a logical/indentation bug.


This is the correct way to create the input:

import random

print('Welcome To Your Password Generator')

chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*().,?0123456789'

number = int(input('Amount of passwords: '))
length = int(input('Input your password length: '))

print('\nHere are your passwords:')

for _ in range(number):
    password = ''
    for _ in range(length):
        password += random.choice(chars)
    print(password)   # moved outside inner loop

I have also learned that for a small project, building string in loops is OK, but join would be faster and a cleaner way to do it For real passwords the secrets module (cryptographically secure) would be recommended instead of random.

 
 
 

Comments


© 2025 by Chrissy. Powered and secured by Wix

bottom of page