def swap(password, swap_type, position_x, position_y):
    """Swap position_x and position_y.

    If swap_type is 'letter' swap indices of corresponding letters.
    """
    if swap_type == 'letter':
        position_x = password.index(position_x)
        position_y = password.index(position_y)
    password[position_x], password[position_y] = (password[position_y],
                                                  password[position_x])
    return password