Return to site

Program a Strong Password Generator in Python

Educators & parents: You can do this Hour of Code Activity as a class or students can work on it independently. If you have any questions or need help, email

How hackable is your password?

These days many aspects of our lives are online - from social media to school files, and family photos to bank information. To make sure all of your private information stays private, one of the most important lines of defense you have against potential hackers is a strong password to protect your data.

If you've ever tried to create an account on any website, you've no doubt seen the password requirements:

  • Must contain at least one lowercase letter
  • Must contain at least one uppercase letter
  • Must contain at least one special character
  • Must be able to hop on one leg while touching your nose 

(maybe not that last one)

Today's project will shed a light on what makes one password better than another and will help you keep prying eyes away from your digital belonging by suggesting some strong password options you may want to try incorporating into your cybersecurity.

Let's start coding!

Part 1:

Go to and choose Python to start coding. First, we'll set up our user input and variables for the app.

Part 2: 

Use a for loop to generate a weak password

Part 3: 

Generate a moderate password

Part 4: 

Generate a strong password (the grand finale!)


You just coded your own Strong Password Generator using user input and for loops. Now you can go forth on the internet knowing a bit more on how to keep your data safe. Try the finished Password Generator here.

Want to code another project? 

Code along with the video below to learn how to code Choose Your Own Adventure Game in Python (3 part project).

If you enjoyed coding with us, check out our YouTube channel for more free coding projects like these! Go to and be sure to like, subscribe and click the bell icon to get notified of our future videos!