I'm getting "ValueError: The number of weights does not match the population" with this code, what can I do to get around it?

Alot of stuff I'd fix here, but to start. random.choice(chars, nums) you can't pass in two sequences, but you can join them. random.choice(chars + nums) for example would work.

but more than that:

def password_creation(user_len, letter_amt, number_amt, chars, nums):
        password = ''.join(random.choice(chars + nums) for _ in range (user_len))
        print ("Your randomly generated password is: " + password)

What's the purpose of the first 3 parameters, if you don't even use them in your function? the way your code is, it doesn't matter how many letters or numbers the user selects, as it has no impact on how you generate the password. i might enter 7 letters and 2 numbers, but the password gives me 5 letters and 4 numbers.

additionally: you first ask how long the password should be. then you ask how many letters. why ask how many numbers? your code should just figure out that if I select a length of 9, and choose 7 letters, then that only leaves room for 2 numbers. At first i thought, oh maybe if i choose 7 letters but 1 number, the remaining character would be a symbol, but it can only be a number, and you ask for how many numbers until i hit 2....why? thats quite frustrating and totally unnecessary.

Lastly:
If you want people to look at your code in the future the more readable it is, the more likely they are to help; I'm just being honest here; I am usually more than happy to help people out, especially if they show they've put in effort, but are stuck on something, I am happy to help them get over the hump, but if the code is just really brutal, horribly formatted, unreadable, hard to follow, it kind of drains that feeling, and I'm less likely to read it all. I'm being honest for your sake, as I know I'm not alone.
Regarding your comments. If they are strictly there for your sake, then fine, do as you wish, but you don't need to explain what is happening, when I or anyone else can clearly just look at the code and see what's happening.

print ("Please enter a valid number!") #if statement to present the user with an error message if they enter an invalid number  

just one example...

but if you do choose to comment PLEASE don't place the comments on the same line as your code. place your comments on a line above or below. in the case of a function: if you want to include a comment about it, thats totally fine, but just format it so its easier on the eyes:

def password_len_input(): #asks the user for the desired length of their password (under 128 characters) and returns that value ready for use in the creation of the password.  

instead:

def password_len_input(): 
    """returns desired length of password given by user. (under 128 characters)"""

the rest of the comment is too wordy; and that's if you need to have one at all.

in anycase:
pass in one list to random.choices - you can join chars and nums by adding them chars + nums but as of now your code doesn't actually use the info entered by user

/r/learnpython Thread