''' 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. ''' import math N1 = 2000 N2 = 3000 pow10 = range(int(math.ceil(math.log(max(N1, N2), 10)))) numlst = [] for i in range(N1, N2+1): k=i even = False check = True for j in pow10[::-1]: if j>0: digit = k/(10**j) k-=digit*(10**j) else: digit = k if digit%2==1: even = False; break else: even = True if even == True: numlst.append(i) print numlst
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question