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?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With