0

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
João Pedro
  • 13
  • 1
  • 4

2 Answers2

3

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'
Eric Duminil
  • 52,989
  • 9
  • 71
  • 124
0

Try it like this:

c = []

for x in range(0, 10):
    c.append(str(x))

print ''.join(c)
zipa
  • 27,316
  • 6
  • 40
  • 58