For my current IT course, I have to make a login window in Python with the following functions:
log in
generate random password
create accounts
As the title suggests, I'm currently stuck on how to make my login window have an option for generating a random ten digit password.
How do this?
Here's a sample of the code that I've written for the project:
import csv
import sys
def main():
menu()
def menu():
print("************Gelos Enterpises Login**************")
print()
choice = input("""
A: Please Register
B: Login
C: Generate Random Password
D: Logout
Please enter your choice: """)
if choice == "A" or choice == "a":
register()
elif choice == "B" or choice == "b":
login()
elif choice == "C" or choice == "C":
generaterandompassword()
elif choice == "D" or choice == "d":
sys.exit
else:
print("You must only select either A or B")
print("Please try again")
menu()
def register():
pass
def login():
pass
# the program is initiated, so to speak, here
main()
CodePudding user response:
From my understanding you just want to make random password right ? So if just random password actually you can use library of string and random
import string
import random
def random_password(size=10, chars=string.ascii_uppercase string.digits):
return ''.join(random.choice(chars) for _ in range(size))
it will be returning random characters.
You can read more in this post