0
I want to print all even numbers from given number to end number
Example input 3,11- output : 4,6,8,10,12,14,16,18,20,22 def even_numbers(start,n): for i in range(start,n): if i%2==0: print(i) even_numbers(3,11)
6 Answers
+ 2
Manoj Bhaagam
Hi! Hereās a way to get 11 even numbers from 3:
https://code.sololearn.com/cDnUBnzv93Py/?ref=app
+ 1
Mind that in range(start, stop) stop is not inclusive.
Your output example doesn't match the task description and the input values, e.g. 20 is not in [3; 11]
+ 1
Per Bratthammar thank you
0
Manoj Bhaagam
Hi! You can take a look at this one:
https://code.sololearn.com/cSpL1tgDV3Ha/?ref=app
0
Per Bratthammar if I take the input (3,11)
I want to print the 11even numbers from 3
0
You can use this:
a = 1
While a <= 20:
If a % 2 == 0:
Print(a)
a = a + 1