-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEven_Number.py
More file actions
20 lines (18 loc) · 765 Bytes
/
Even_Number.py
File metadata and controls
20 lines (18 loc) · 765 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# Write a program, which will find all such numbers between 1000 and 3000 (both included) such that each digit of the
# number is an even number. The numbers obtained should be printed in a comma-separated sequence on a single line.
#
# Hints:
# In case of input data being supplied to the question, it should be assumed to be a console input.
b = []
for i in range(1000, 3000):
a = str(i)
if (int(a[0]) % 2 == 0) and (int(a[1]) % 2 == 0) and (int(a[2]) % 2 == 0) and (int(a[3]) % 2 == 0):
b.append(a)
print(",".join(b))
# for three digit numbers
items = []
for i in range(100, 401):
s = str(i)
if (int(s[0]) % 2 == 0) and (int(s[1]) % 2 == 0) and (int(s[2]) % 2 == 0):
items.append(s)
print(",".join(items))