I am not sure, whether I should use for -loop. Perhaps, like
for i in range(145):
by 6: //mistake here?
print i
I am not sure, whether I should use for -loop. Perhaps, like
for i in range(145):
by 6: //mistake here?
print i
I would prefer:
for i in xrange(25): # from 0 to 24
print 6*i
You can easily build a list containing the same numbers with a similar construct named list comprehension:
numbers = [6*i for i in xrange(25)]
print numbers
If you already have a list of (unknown) numbers, say someNumbers
, but you want to print only those which are multiples of 6:
for i in someNumbers:
if i%6 == 0:
print i
for i in range(0,150,6):
print i
if you are stepping by a constant
i = 1
while i * 6 < 144:
i = i + 1
print i * 6
There are plenty of ways to do this