Use a while loop with if statement condition i % 2 == 0 then only print the first 10 even numbers in Python. Simple example code print even numbers of user input value using a while loop in Python. You can use list objects to store value, here we are printing the value using the end keyword.x = int[input["Enter a number: "]]
i = 1
while i > i = 2
>>> while i >> for i in range[2, 11, 2]: # Using for
... print[i]
...
2
4
6
8
10
answered Oct 17, 2016 at 19:49
Moinuddin QuadriMoinuddin Quadri
44.6k12 gold badges92 silver badges117 bronze badges
This is what I'd try:
i=2
while i