0
How many integers (I get 7)?
a =[] For i in range (1,10) if(i%2==0) or (i%3==0): a.append(i) Solution:6 Range 1,10 is 1-9. So: 1,2,3,4,6,8,9 or a total of 7 numbers should be the answer. What am I missing? Any help appreciated.
3 Réponses
+ 1
The variable a should be [2, 3, 4, 6, 8, 9].You are appending only those numbers which are divisble by 2 or 3.
+ 1
I see! Thanks (1%2=!0). My mistake.
0
Thanks Ankit!