I’m writing a simple program to generate random passwords based on the user’s name. The program asks for the name, shuffles the letters, and appends some random numbers at the end.
Here is my code:
import random as rd
def reading_name():
name = input("Please enter your name: ").lower() #
return name
def create_random_password(name):
list = list(name)
rd.shuffle(list)
numbers= [str(rd.randint(0, 9)) for _ in range(5)]
password = list + numeros
password = ''.join(password)
return password
if __name__ == "__main__":
name = reading_name()
print(f"Here is your password {creat_random_password(name)}")
I’d love to know if there are any ways to improve this code, both in terms of readability and performance. Any suggestions for best practices or adjustments I could make?
devSants is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
7