How to print a list with integers without the brackets, commas and no quotes? [duplicate]

This is a list of Integers and this is how they are printing:

[7, 7, 7, 7] 

I want them to simply print like this:

7777 

I don't want brackets, commas or quotes. What to do?

0

5 Answers

If you're using Python 3, or appropriate Python 2.x version with from __future__ import print_function then:

data = [7, 7, 7, 7] print(*data, sep='') 

Otherwise, you'll need to convert to string and print:

print ''.join(map(str, data)) 
2

Try this:

print("".join(str(x) for x in This)) 

Using .format from Python 2.6 and higher:

>>> print '{}{}{}{}'.format(*[7,7,7,7]) 7777 >>> data = [7, 7, 7, 7] * 3 >>> print ('{}'*len(data)).format(*data) 777777777777777777777777 

For Python 3:

>>> print(('{}'*len(data)).format(*data)) 777777777777777777777777 
3

You can convert it to a string, and then to an int:

print(int("".join(str(x) for x in [7,7,7,7]))) 
6

Something like this should do it:

for element in list_: sys.stdout.write(str(element)) 
0

You Might Also Like