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!

3

2 Answers 2

1

Use join:

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

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

Sign up to request clarification or add additional context in comments.

2 Comments

What if the list is very long?
You can use the spread operator, decrypted_word = ' '.join([...decrypted_characters]) this will spread your array out, and the above suggestion should work nicely
1
decrypted_characters = ['mathematician', 'to', 'present', 'a', 'proof', 'of', 'the', 'sensitivity']
decrypted_word = ' '.join(decrypted_characters)
print(decrypted_word)

Try this out.

2 Comments

How is this different than the existing answer?
@cricket_007 this is close enough but I am just keeping same format with minimum change to that guy who asked question get it correctly with minimum effort.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.