4

When I print an array:

 pi = [3,1,4,1,5,9,2,6,5]
 print pi

It prints like normal:

 [3, 1, 4, 1, 5, 9, 2, 6, 5]

I was wondering if I could print like:

 314159265

If so how?

Ashwini Chaudhary
  • 244,495
  • 58
  • 464
  • 504

1 Answers1

8

You can use str.join:

>>> pi = [3,1,4,1,5,9,2,6,5]
>>> print ''.join(map(str, pi))
314159265

Or print function:

>>> from __future__ import print_function  #not required in Python 3
>>> print(*pi, sep='')
314159265
Ashwini Chaudhary
  • 244,495
  • 58
  • 464
  • 504