+ 1

how to make a loop displaying even numbers up to 20? on python

i tried using something like: x=0 while x<=20: print(x) x=x+2: but it keeps giving me error

7th Feb 2018, 11:25 AM
Adam Lamber
Adam Lamber - avatar
6 odpowiedzi
+ 5
I wrote this for odd numbers but you will get the idea https://code.sololearn.com/cqJUKgH6zn1D/?ref=app
7th Feb 2018, 11:55 AM
Louis
Louis - avatar
+ 2
for i in range(0, 21): if i % 2 == 0: print(i)
7th Feb 2018, 11:28 AM
Mike Shaw
Mike Shaw - avatar
7th Feb 2018, 11:28 AM
Adam Lamber
Adam Lamber - avatar
0
ok thanks ill try
7th Feb 2018, 11:29 AM
Adam Lamber
Adam Lamber - avatar
0
it works as i intended, thanks!
7th Feb 2018, 11:36 AM
Adam Lamber
Adam Lamber - avatar
- 1
post the code here so we can see the problem.
7th Feb 2018, 11:26 AM
Jonathan Pizarra (JS Challenger)
Jonathan Pizarra (JS Challenger) - avatar