Это пример кода того, как я прошу пользователя ввести данные.
Код: Выделить всё
while True:
try:
lower = list(string.ascii_lowercase)
lower_low = 6
lower_high = 24
lower_choice = int(input("How many lower case letters would you like in your password? "))
if lower_choicelower_high:
print("The selection must be" ,lower_low,"or higher or", lower_high,"and lower. Please choose again. ")
continue
break
except ValueError:
print("Invalid input. Please try again.")
print("You have choosen", lower_choice,"lowercase letters to be used in your password.")
Код: Выделить всё
def password_gen():
special = (string.punctuation)
lower_choice = (string.ascii_lowercase)
upper_choice = (string.ascii_uppercase)
password = ''
for p in range(38):
password += random.choice(special+lower_choice+upper_choice)
return password
password = password_gen
print(password)
Подробнее здесь: https://stackoverflow.com/questions/786 ... rd-with-se