0

I have a list 'decrypted_characters' that looks like this

['mathematician', 'to', 'present', 'a', 'proof', 'of', 'the', 'sensitivity']

I want it to look like a paragraph so I tried

decrypted_word = ''.join(decrypted_characters)

and when I print it looks like

mathematiciantopresentaproofofthesensitivity

How to add spaces after each element so that it looks like sentence? I want it to look like

mathematician to present a proof of the sensitivity

Thanks!

Siddharth C
  • 39
  • 1
  • 9
  • 1
    Possible duplicate of [Concatenate item in list to strings](https://stackoverflow.com/questions/12453580/concatenate-item-in-list-to-strings) – rafaelc Sep 15 '19 at 23:29
  • So many dupes, pick one: [here](https://stackoverflow.com/questions/12453580/concatenate-item-in-list-to-strings), [here], [here](https://stackoverflow.com/questions/8546245/python-concat-string-with-list), [here](https://stackoverflow.com/questions/29566527/concatenate-python-string-from-list-entries) etc – rafaelc Sep 15 '19 at 23:31
  • Possible duplicate of [Python concat string with list](https://stackoverflow.com/questions/8546245/python-concat-string-with-list) – OneCricketeer Sep 16 '19 at 05:45

2 Answers2

1

Use join:

In [4]: ' '.join(['mathematician', 'to', 'present', 'a', 'proof', 'of', 'the', 'sensitivity'])

Out[4]: 'mathematician to present a proof of the sensitivity'

jmromer
  • 2,212
  • 1
  • 12
  • 24
1
decrypted_characters = ['mathematician', 'to', 'present', 'a', 'proof', 'of', 'the', 'sensitivity']
decrypted_word = ' '.join(decrypted_characters)
print(decrypted_word)

Try this out.

Vashdev Heerani
  • 660
  • 7
  • 21