#Suppose we have a list of numbers and a target value. Write a Python program to find all the combinations of list elements whose sum equals the target value.

#For example,

# list of numbers
#numbers = [1, 5, 6, 3, 2, 4]

#target value = 7

#All the combinations of list numbers whose sum is 7 are

#1 and 6
#5 and 2
#4 and 3

# replace ___ with your code

# define a function to find the elements that can make target sum
def find_sum(numbers, target):

    # initialize the temporary list to avoid duplicates
    temp_list = []

    # loop through the list
    for i in numbers:
        
        # if the difference of target and current element
        # is in the temporary list,
        # print the difference and the current element
        if target - i in temp_list:
            print(f"{target-i} {i}")

        # add the current element to the temporary list
        temp_list.append(i)

# using list comprehension ... 
# define a function to find the elements that can make target sum

def find_sum1(numbers, target):
    rlst = [(x, y) for i, x in enumerate(numbers) for y in numbers[i+1:] if x + y == target]
    return rlst


numbers = [1, 5, 6, 3, 2, 4]
target= 7
result = find_sum1(numbers, target)
print(result)

#Explanation:
#
#    The outer loop iterates over x and its index i in numbers.
#    The inner loop iterates over the remaining elements in numbers after x, which ensures that each pair (x, y) is considered only once and avoids duplicates like (6, 1) when (1, 6) is already found.
#    The condition x + y == target checks if the sum of the pair equals the target.
#to find the total number of special characters in a string. Use the following inbuilt Python functions:
#
## Complete the function below
#
# define a function
def character_counter(string):

    counter = 0

    for s in string:
        lst = [not s.isalpha(), not s.isdigit(), not s.isspace()]
        if all(lst):
            counter += 1
    return counter

# Write a function to remove duplicates from a list...
my_list = [2, 'python', 5, 7, 'python', 'java', 5, "last word"]

def double_check(lst):
    rlst = []
    for i in lst:
        if i not in rlst:
            rlst.append(i)
    return rlst

# Write a function to remove duplicates from a list using list comprehension...

def dbl_chk(lst):
    #   rlst = [y for y in lst if y not in lst] how not to do it, lol!
    return [i for n, i in enumerate(lst) if i not in lst[:n]]