[Solved] Python .join() format error


It was already said that the delimiter is inserted between each element not added to each element.

However you can easily create a new list with the correctly added bear, for example:

>>> lst = ['brown', 'polar', 'grizzly', 'sun', 'kodiak']
>>> newlst = [item + ' bear' for item in lst]
>>> print('\n'.join(newlst))
brown bear
polar bear
grizzly bear
sun bear
kodiak bear

This adds a bear to each list item and then inserts a newline between the items.

You can also prepend it to each list item:

>>> newlst = ['bear ' + item for item in lst]
>>> print('\n'.join(newlst))
bear brown
bear polar
bear grizzly
bear sun
bear kodiak

solved Python .join() format error