Script to generate random password I made this random password script. It works, but i think it is kind of bloated. The part where random characters are being added is the area where I think it needs work. I don't want to declare if and else statement for every combination of lowercase list, uppercase list and digits list(I am taking input from user whether they want uppercase,lowercase,digits or any possible combination of these three). Is there any possible way in which I can just check which of these three values are yes and then just use only those.
 Also what is more efficient using lower() to turn the list called using string module into lower case or just calling the lowercase list itself.
import random
from  string import ascii_letters ,digits
while True:
    userchoice_size = int(input(&quot;Enter the length of the password : &quot;)) # Asks for length of password
    userchoice_syntax_lower = input(&quot;Do you want lower case letter?(y or n) &quot;)
    userchoice_syntax_upper = input(&quot;Do you want upper case letter?(y or n) &quot;)
    userchoice_syntax_number = input(&quot;Do you want numbers?(y or n) &quot;)
    counter=0
    password='' # String which stores the password
    choice_list=[1,2,3]
    while counter &lt;= userchoice_size:
        choice_number = random.choice(choice_list)
        if choice_number == 1:
            if userchoice_syntax_upper == 'y': # Uppercase list
                password = password + str(random.choice(ascii_letters.upper())) 
                counter += 1
        if choice_number == 2:
            if userchoice_syntax_number=='y': # Digits list
                password = password + str(random.choice(digits))
                counter += 1
        if choice_number == 3:
            if userchoice_syntax_lower == 'y': # Lower case list
                password= password + str(random.choice(ascii_letters.lower())) # Converts all letters into lowercase then randomly select and store in list
                counter += 1
    print (password)
Character distribution
You randomly choose between uppercase, lowercase and digit characters with an equal probability, but there are more letters than digit characters. That means characters will be under-represented in your password's probability distribution. Easier and more accurate is to make one string of all eligible characters and choose from it randomly.
Redundant str
No need for str here:
str(random.choice(ascii_letters.upper())) 

Move your increment
counter += 1

should not be repeated three times in if statements. You can do it once at the end of the loop. Better yet,
for _ in range(userchoice_size):

Choice list
This:
choice_list=[1,2,3]
choice_number = random.choice(choice_list)

should not use a list, and should be replaced with a call to randrange.
Secure entropy
For password generation it's crucially important to use a secure source of entropy. Read this quote carefully:

Python uses the Mersenne Twister as the core generator. It produces 53-bit precision floats and has a period of 2**19937-1. The underlying implementation in C is both fast and threadsafe. The Mersenne Twister is one of the most extensively tested random number generators in existence. However, being completely deterministic, it is not suitable for all purposes, and is completely unsuitable for cryptographic purposes.

Emphasis mine. A better built-in option is secrets.