-3

I have written a code that ends up outputting what I want but in list format. Just to make it easier to understand, I will make up an input.

If I get

>>>
['H','e','l','l','o',' ','W','o','r','l','d']

as an output, how can I change it to:

>>>
'Hello World'

I have tried using .join() but it tells me that it does not work with lists as an error code.

If you need any more information, or I am being vague, just leave a comment saying so and I will update the question.

And if you leave a downvote, can you at least tell me why so that I can fix it or know what to improve for later posts

matt6297
  • 81
  • 7

2 Answers2

4

You join on the connector like this: ''.join(['H','e','l','l','o',' ','W','o','r','l','d'])

Alper
  • 3,424
  • 4
  • 39
  • 45
1

Just use join method by passing a list as parameter.

str = ''.join(['H','e','l','l','o',' ','W','o','r','l','d'])
Mihai Alexandru-Ionut
  • 47,092
  • 13
  • 101
  • 128