I think you are conflating a list comprehension with str.join method.
A list comprehension always produces a new list. Three ways list may be produced that is the same as g
>>> [x for x in 'axp']
['a', 'x', 'p']
>>> [x[0] for x in ['alpha', 'xray', 'papa']]
['a', 'x', 'p']
>>> list('axp')
['a', 'x', 'p']
Since g
is already strings, you use join to produce a single string to print it:
>>> g=['a', 'x', 'p']
>>> ''.join(g)
'axp'
To print it, just use join with the separator desired:
>>> print('\n'.join(g))
a
x
p
You would need to use a comprehension if the elements of the list are not compatible with join by being strings:
>>> li=[1,2,3]
>>> '\n'.join(li)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: sequence item 0: expected str instance, int found
>>> print('\n'.join(str(e) for e in li))
1
2
3