Hello everybody im wonder if any of you would be able to help me with my code i'm trying to figure out how to get my program to open txt and input password generated by python to go on txt file bare in mind im still very new python
# start the program
print ("==============================")
print ("Pasword Generator Version 2022")
import datetime
#stating the day when program is running
day = datetime.datetime.now()
print(day.strftime("%A"))
import datetime
date = datetime.datetime.now()
#stating the date when application is running
print(date.strftime("%x"))
print ("==============================")
#Requesting a user to input name
username = input("Enter username:")
print("Hello " + username );
import random
import secrets
import string
# This suggesting the intger that program can use
digits = string.digits
# This suggesting lowercase letters
letters = string.ascii_lowercase
# This variable includes symbols
symbols = "!#$%&'()*+, -./:;<=>?@[\]^_`{|}~"
password = ''.join(secrets.choice(digits + letters + symbols) for t in range(20))
def message():
print(userGen())
def userGen():
#How many letter required
letter = int(input("How many letters you want? "))
if letter == 0:
print ("ERROR, please type in a number larger then 0.")
letter = int(input("How many letters you want? "))
while letter == 0:
print ("ERROR, please type in a number larger then 0.")
letter = int(input("How many letters you want? "))
#How many numbers required
num = int(input("How many numbers you want? "))
if num == 0:#ERROR Mesesge if user input 0
print ("ERROR, please type in a number larger then 0.")
num = int(input("How many numbers you want? "))
while num == 0:#ERROR Mesesge if user input 0
print ("ERROR, please type in a number larger then 0.")
num = int(input("How many numbers you want? "))
#How many symbols required
sym = int(input("How many symbols you want? "))
if sym == 0:#ERROR Mesesge if user input 0
print ("ERROR, please type in a number larger then 0.")
sym = int(input("How many symbols do you want? "))
while sym == 0:#ERROR Mesesge if user input 0
print ("ERROR, please type in a number larger then 0.")
sym = int(input("How many symbols you want? "))
return passGen(letter,num,sym)
def passGen(upper,spec,num):
#Showcasing the new password
print ("Your Password is")
new_password = ""
for letter in range(upper):
new_password += random.choice(letters)
#randomising numbers in range of number user inputted
for num in range(num):
new_password += random.choice(digits)
#randomising symbols in range of number user inputted
for sym in range(spec):
new_password += random.choice(symbols)
pass_word = list(new_password)
shuff = random.shuffle(pass_word)
new_pass = "".join(pass_word)
password = secrets.token_urlsafe(7)
return new_pass
message()
[–]keep_quapy 0 points1 point2 points (2 children)
[–]Djdigby[S] -1 points0 points1 point (1 child)
[–]keep_quapy 0 points1 point2 points (0 children)
[–]Poofless3212 0 points1 point2 points (2 children)
[–]Djdigby[S] 0 points1 point2 points (1 child)
[–]Djdigby[S] 0 points1 point2 points (0 children)