-3
def chek(x):
    if x%3==0:
        return False
    return True
a=sum([i for i in range(6) if chek(i)])
print(a)
ShadowRanger
  • 124,179
  • 11
  • 158
  • 228
Rippar
  • 23
  • 3

1 Answers1

2
[i for i in range(6) if chek(i)]

produces [1, 2, 4, 5], omitting 0 and 3 because they have a remainder of 0 when divided by 3, and therefore are not included in the listcomp output. The sum of 1, 2, 4 and 5 is 12.

ShadowRanger
  • 124,179
  • 11
  • 158
  • 228