So I want to write a Python code, which creates a random password for the user. It needs to ask the user how long they want their password to be, and have a minimum set of characters.

I have tried to search for something for many weeks and I just can't find it, so sorry if this has already been solved.

Here is the code I have so far, don't know what other piece of code I need and where I have to use in order to get what I want.

```
import random
import secrets
import string

# This variable includes numbers
digits = string.digits

# This variable includes uppercase and 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("Hello, here is a password generator: ")
    print("Choose the length?")
    print(userGen())

def userGen():
    upper = int(input("How many letters you want? "))
    spec = int(input("How many symbols you want? "))
    num = int(input("How many numbers you want? "))
    return passGen(upper,spec,num)

def passGen(upper,spec,num):
    new_password = ""
    for i in range(upper):
        new_password += random.choice(letters)
    for x in range(spec):
        new_password += random.choice(symbols)
    for y in range(num):
        new_password += random.choice(digits)

    pass_word = list(new_password)
    shuff = random.shuffle(pass_word)
    new_pass = "".join(pass_word)
    password = secrets.token_urlsafe(7)
    return new_pass

message()

```