sqy201x's picture
Publish humaneval: 164 task(s) (openai/openai_humaneval)
b83572f verified
Raw
History Blame Contribute Delete
339 Bytes
def solution(lst):
"""Given a non-empty list of integers, return the sum of all of the odd elements that are in even positions.
Examples
solution([5, 8, 7, 1]) ==> 12
solution([3, 3, 3, 3, 3]) ==> 9
solution([30, 13, 24, 321]) ==>0
"""
return sum([x for idx, x in enumerate(lst) if idx%2==0 and x%2==1])