Is there anyway to use less if statements in my function? I have made a random password generator using a class called password and a method called generate.
My program works as it should. It generates a random password determined by the users preferences for length, upper or lowercase, numbers and special characters.
I was just wondering if there was a way to refactor the numerous if statements I have used to determine what sort of password the program would generate.
Any other suggestions for improvements I could make would also be helpful. Thanks a ton :D
Code:
import random
import string

class password:
    def __init__(self, length, string_method, numbers=True, special_chars=False):
        self.length = length
        self.string_method = string_method
        self.numbers = numbers
        self.special_chars = special_chars

    def generate(self, iterations):

        # Checking what type of string method the user has asked for

        if self.string_method == 'upper':
            stringMethod = string.ascii_uppercase
        elif self.string_method == 'lower':
            stringMethod = string.ascii_lowercase
        elif self.string_method == 'both':
            stringMethod = string.ascii_letters

        # Checking if the user has asked for numbers or not

        if self.numbers == True:
            stringNumbers = string.digits
        elif self.numbers == False:
            stringNumbers = ''

        # Checking if the user has asked for special characters or not

        if self.special_chars == True:
            stringSpecial = string.punctuation
        elif self.special_chars == False:
            stringSpecial = ''

        characters = stringMethod + stringNumbers + stringSpecial

        # Generating the password

        for p in range(iterations):
            output_password = ''
            for c in range(self.length):
                output_password += random.choice(characters)
            print(output_password)

# Test

password1 = password(20, 'lower', True, False) # password length = 20, string method is lowercase, numbers are true and special characters are false
password1.generate(3) # generate the random password 3 times```
You can use the ternary operation to reduce the vertical space, i.e. x = a if condition else b. This sets x to a if condition is true and to b otherwise.
You can also use a dictionary to map a string to some object, like
the_map = {'a': 4, 'b': 7, 'c': 43}`
x = the_map['c']

This will set x to 43.
Then you can evaluate everything in the initializer instead. So it's not less if checks per se, but it's a bit cleaner, and you can call generate multiple times without needing to do the checks.
import random
import string

class Password:
    def __init__(self, length, string_method, numbers=True, special_chars=False):
        self.length = length
        self.string_method = {
            'upper': string.ascii_uppercase,
            'lower': string.ascii_lowercase,
            'both':  string.ascii_letters
        }[string_method]
        self.numbers = string.digits if numbers else ''
        self.special_chars = string.punctuation if special_chars else ''

    def generate(self, iterations):
        characters = self.string_method + self.numbers + self.special_chars

        # Generating the password
        for p in range(iterations):
            output_password = ''
            for c in range(self.length):
                output_password += random.choice(characters)
            print(output_password)

# Test

password = Password(20, 'lower', True, False)
password.generate(3) # generate the random password 3 times

If you actually want less checks, then just pass in the characters directly. Passing in the length and which characters you want to use into password generator seems perfectly legitimate and straight-forward. This also allows you to do more complex things like generating a password with just vowels, without even numbers, or maybe if you want to exclude certain punctuation.
import random
import string

class Password:
    def __init__(self, length, characters):
        self.length = length
        self.characters = characters

    def generate(self, iterations):
        # Generating the password    
        for p in range(iterations):
            output_password = ''
            for c in range(self.length):
                output_password += random.choice(self.characters)
            print(output_password)

# Test

password = Password(20, string.ascii_lowercase + string.digits)
password.generate(3) # generate the random password 3 times