I'm work on a problem which I set myself for fun, which is to create a python script which prints the even numbers from 0 to 100. The challenge is to make the script as small as possible. This is what I have so far:
for x in range(0, 101):
if (x % 2 == 0):
print x
Currently it is 60 bytes. Can anyone think of a way to make it smaller?
Edit: print(*range(2,101,2),sep='\n')
which is 30 bytes. Any smaller?
i=2;exec"print i;i+=2;"*50
\$\endgroup\$0
or2
? I don't python much, but it looks to me like your two examples do different things. Please correct me if not. \$\endgroup\$print "0 10 100"
(is binary OK?) \$\endgroup\$