20 lines
647 B
Python
20 lines
647 B
Python
def double_the_difference(lst):
|
|
'''
|
|
Given a list of numbers, return the sum of squares of the numbers
|
|
in the list that are odd. Ignore numbers that are negative or not integers.
|
|
|
|
double_the_difference([1, 3, 2, 0]) == 1 + 9 + 0 + 0 = 10
|
|
double_the_difference([-1, -2, 0]) == 0
|
|
double_the_difference([9, -2]) == 81
|
|
double_the_difference([0]) == 0
|
|
|
|
If the input list is empty, return 0.
|
|
'''
|
|
if not lst:
|
|
return 0
|
|
|
|
result = 0
|
|
for num in lst:
|
|
if isinstance(num, int) and not isinstance(num, bool) and num > 0 and num % 2 == 1:
|
|
result += num ** 2
|
|
return result |