Python how to print output

4

How can I print a list in this way, for example:

l=[4,26,32]

I want to print the output as follows:

4 26 32

No comma and with a blank space on the same line. Thank you in advance.

    
asked by anonymous 24.02.2016 / 02:29

2 answers

4

Use the join method and map . This also has the advantage of being portable between the Python 2.x and 3.x versions.

See the example:

l=[4,26,32]

print(' '.join(map(str, l)))

Output:

  

4 26 32

Source: link

    
24.02.2016 / 03:11
1

This is simple!

print (str(l[0]) + ' ' + str(l[1]) + ' ' + str(l[2]))

Handling in list:

for i in l:
   print (str(i) + ' ', end="");
    
24.02.2016 / 02:36