Skip to content

Commit 01408a7

Browse files
authored
Update Print_List_of_Even_Numbers.py
Added support for python 2.
1 parent 2c69b35 commit 01408a7

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

Print_List_of_Even_Numbers.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,25 @@
1-
#user can give in put now
2-
#pyhton3
1+
#user can give input now
2+
#python3
3+
4+
import sys
5+
6+
if sys.version_info[0]==2:
7+
version=2
8+
else:
9+
version=3
10+
11+
if version==2:
12+
n=input('Enter number of even numbers to print: ')
13+
printed=0
14+
numbers=0
15+
while printed!=n:
16+
if numbers%2==0:
17+
print numbers,
18+
printed+=1
19+
numbers+=1
20+
21+
if version==3:
22+
print ([x for x in range(int(input()),int(input())) if not x%2])
23+
24+
325

4-
print ([x for x in range(int(input()),int(input())) if not x%2])

0 commit comments

Comments
 (0)