I want to make a function that takes a list as input and returns the sum of integers, real numbers, and complex numbers among the elements of the list. As elements of the list, data type objects other than integers, real numbers, and complex numbers are excluded when calculating the sum.
So I wrote the code like this way
def number_sum(lst):
total = 0
for e in lst:
if type(e) == int or type(e) == float or type(e) == complex:
total += e
return total
x1 = [1, 3, 5, 7, 9] # 25
x2 = ["abc", [3, 5], 3.5, 2+3j, 4.5, 10] # 20 + 3j
x3 = [] # 0
print(number_sum(x1))
print(number_sum(x2))
print(number_sum(x3))
but I want I can take the x1, x2, x3 lists in input. How can I fix it?