0
I dno't understand it.
So I'm at this challenge and I don't understand how to do it. Create a list of multiples of 3 from 0 to 20. a = _i for i in range(20) _i% _==0] Every time I've put an "underscore" that's a blank space.
1 ответ
+ 1
Create a list of multiples of 3 from 0 to 20.
a = [i for i in range(20) if i%3==0]
So, it is like this:
For loop runs from 0 to (20-1)=>19
In every loop, it checks if i is divisible by 3 i.e. i%3==0
If it is true, it is added in the list else discarded
That's basically it...
In long code:
a = []
for i in range(20):
if i%3==0:
a.append(i)