Just need to print:
0123456789
Instead of this, independent of the list size:
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
Here is the code example:
c = []
for x in range(0, 10):
c.append(x)
print c
Just need to print:
0123456789
Instead of this, independent of the list size:
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
Here is the code example:
c = []
for x in range(0, 10):
c.append(x)
print c
You could use join
to join your elements together, but they need to be strings.
If you have integers, use str
function with map
first.
>>> l = range(10)
>>> ''.join(map(str, l))
'0123456789'
Without map
, you could also write :
>>> ''.join(str(i) for i in range(10))
'0123456789'
Try it like this:
c = []
for x in range(0, 10):
c.append(str(x))
print ''.join(c)