Does any one know how to print this pattern using python?
0000000001 0000000002 0000000003 0000000004 0000000005 0000000006 0000000007 0000000008 0000000009 0000000010 0000000011
I am a beginner here..Pls help..
Does any one know how to print this pattern using python?
0000000001 0000000002 0000000003 0000000004 0000000005 0000000006 0000000007 0000000008 0000000009 0000000010 0000000011
I am a beginner here..Pls help..
Use zfill(n) function of str class to fill zeros on the left of the string to make it of some length n.
>>> for i in range(1,15):
... print str(i).zfill(10),
...
0000000001 0000000002 0000000003 0000000004 0000000005 0000000006 0000000007 0000000008 0000000009 0000000010 0000000011 0000000012 0000000013 0000000014
you can also use rjust:
>>> for x in range(20):
... print str(x).rjust(10,'0'),
...
0000000000 0000000001 0000000002 0000000003 0000000004 0000000005 0000000006 0000000007 0000000008 0000000009 0000000010 0000000011 0000000012 0000000013 0000000014 0000000015 0000000016 0000000017 0000000018 0000000019
using format:
>>> for x in range(20):
... print "{:0>10}".format(x),
...
0000000000 0000000001 0000000002 0000000003 0000000004 0000000005 0000000006 0000000007 0000000008 0000000009 0000000010 0000000011 0000000012 0000000013 0000000014 0000000015 0000000016 0000000017 0000000018 0000000019