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.

2nd Apr 2019, 7:12 AM
tristach605
tristach605 - avatar
3 Answers
+ 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.
2nd Apr 2019, 7:18 AM
Ankit
Ankit - avatar
+ 1
I see! Thanks (1%2=!0). My mistake.
2nd Apr 2019, 7:23 AM
tristach605
tristach605 - avatar
0
Thanks Ankit!
2nd Apr 2019, 7:24 AM
tristach605
tristach605 - avatar