Python Password Generator

I have been expanding on my coding knowledge by learning a new language and a language that I saw as being very popular Python and I think is useful to know is Python. Early on in 100 Days of Code — The Complete Python Pro Bootcamp for 2021 course on Udemy one of the projects you build is a Random Password Generator in which you enter the number of letters, numbers, and symbols you want your password to have and it returns a random password.

Photo by Jason Dent on Unsplash

This can be useful in that its randomness is creating very secure passwords that would be hard to crack, however not the most practical or ideal as they would also be very hard for the user to remember. Here is the code for the generator and I will then explain it further

In the beginning, we import random which we use later to pick random letters, numbers, and symbols as well as shuffle our password. The python docs explain random in more detail and more uses for random here https://docs.python.org/3/library/random.html. Then we have our letters, numbers, and symbols (typically used in passwords) listed out so we are able to choose from them randomly with random.choice. The number of letters, numbers, or symbols placed in our password list is based on what the user enters so within our for loop we have a range that goes from 1 to the number the user entered + 1 so the loop runs the same amount of times as the user's input. This list is then shuffled with random.shuffle (again the documentation listed above talks more on this). Lastly, the password list is put into a string to be printed with a simple for loop placing each character from the list to a string. Below is an example of this code then being run in the terminal