Skip to content

Instantly share code, notes, and snippets.

@raghavmri
Last active July 3, 2022 14:08
Show Gist options
  • Save raghavmri/2cb51abbcb68831a3d16f5a9c94c8155 to your computer and use it in GitHub Desktop.
Save raghavmri/2cb51abbcb68831a3d16f5a9c94c8155 to your computer and use it in GitHub Desktop.
import random
import string
# In this video, we'll create a simple random password generator for staying safe.
# Let's import the required modules first
# Now we will create a function to generate random characters
def generateChar(length: int):
return "".join(random.choice(list(string.ascii_letters+string.digits+"@!#$%^&*()")) for i in range(length))
# We will create a loop for the users to generate multiple passwords
while True:
# Let's ask the user how many characters they want in their password
length = int(
input("Please input the length of the password to be generated: "))
# Some decoration for the user and the generated password
print("\n********************************************************")
print("\nYour Password is", generateChar(length), "\n")
print("********************************************************\n")
# Let's ask the user if they want to generate another password
if input("Would you like to generate another password(N/Y): ").lower() == "n":
# If the user doesn't want to generate another password, we will exit the program
break
continue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment