How to print a list without it showing brackets and "" in the output ? Python 3.3.2

10,093

Solution 1

With Python 3, you can pass a separator to print. * in front of myList causes myList to be unpacked into items:

>>> print(*myList, sep='')
abc

Solution 2

Use str.join():

''.join(myList)

Example:

>>> myList = ["a", "b", "c"]
>>> print(''.join(myList))
abc

This joins every item listed separated by the string given.

Share:
10,093
dkentre
Author by

dkentre

Updated on June 13, 2022

Comments

  • dkentre
    dkentre almost 2 years

    So say I have a list named myList and it looks something like this :

    myList = ["a", "b", "c"]
    

    How would you print it to the screen so it prints :

    abc 
    

    (yes, no space inbetween)

    If I use print(myList) It prints the following:

    ['a', 'b', 'c']
    

    Help would be much appreciated.