5

I have this array of strings that I have split element wise so I can do stuff to it. Now I want to return them back into a sentence.

my_array = (['T', 'e', 's', 't', ' ', 'w', 'o', 'r', 'd', 's', '!'])

Is there a way to join them togeter back into a sentence whilst keeping the formatting? Ideal output would be something similar to the following:

joined_array = (['Test Words!'])
KGreen
  • 123
  • 5
  • 9

2 Answers2

8

Try join:

my_array = (['T', 'e', 's', 't', ' ', 'w', 'o', 'r', 'd', 's', '!'])
joined_array = ''.join(my_array)

Which gives:

'Test words!'
funie200
  • 3,688
  • 5
  • 21
  • 34
2
joined_array = ''.join(my_array)
MetallimaX
  • 594
  • 4
  • 13