I am a complete beginner in Python and I want to generate a random string based on user input for a password generator I currently have the below:
import random
import string
print("Password Generator")
def lower(length):
lower_case = string.ascii_lowercase
generate = ''.join(random.choice(lower_case) for i in range(length))
amount_of_characters = input("How many characters do you want?")
I want the input of the user to equal the length of the random string.
For example if the user inputted 36 the string generated is 36 characters long.
>Solution :
import random
import string
print("Password Generator")
def gen(length):
lower_case = string.ascii_lowercase
generate = ''.join(random.choice(lower_case) for i in range(length))
return generate
amount_of_characters = int(input("How many characters do you want?"))
print(gen(amount_of_characters))