0
If here someone who can explain this..
y=10 w=30 print([i for i in range(y,w,3) if i%2==1][2]) answer -25 plz explain
5 Answers
+ 1
Harsh Mamgai the original list has the powers of 2 from 0 to 3
(0, 1, 4, 9)
then it is filtered to even numbers
(0, 4)
and 0 + 4 is 4, so the answer is 4
+ 2
i'm getting 25, not -25 and here's the logic:
the code lists all the numbers between 10 and 30 with a step of 3
(10, 13, 16, 19, 22, 25, 28)
but here they are filtered to only be odd numbers
(13, 19, 25)
so, the third element is 25
+ 1
thanks đđ
0
here one question more for you.
r=[j**2 for j in range (4) if j**2%2 ==0]
print (r[0]+r[1])
0
answer is 4 plz explain