-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
  • 143,180
  • 12
  • 188
  • 271
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
  • 143,180
  • 12
  • 188
  • 271