0

Lets say I have:

hello = list(xrange(100))
print hello

The result is:

1, 2, 3, 4, 5, 6, 7, 8, 9, 10...

I need to remove all those spaces from the list so it can be like:

1,2,3,4,5,6,7,8,9,10...
Chris Martin
  • 30,334
  • 10
  • 78
  • 137
ney
  • 3
  • 1

1 Answers1

0

Since join takes string objects, you need to convert those items explicitly to strings. For example:

hello = ','.join(list(xrange(100)))
TypeError: sequence item 0: expected string, int found

So:

hello = xrange(100)
print ''.join([str(n) for n in hello])

Note there is no need for the list().

cdarke
  • 42,728
  • 8
  • 80
  • 84