[Solved] How to print a list without [ , ” in python


Assuming that your list is:

this_is_a_list = ['*', 'I', 'B', 'M', ' ', 'i', 's', ' ', 'a', ' ', 't', 'r', 'a', 'd', 'e', 'm', 'a', 'r', 'k', ' ', 'o', 'f', ' ', 't', 'h', 'e', ' ', 'I', 'n', 't', 'e', 'r', 'n', 'a', 't', 'i', 'o', 'n', 'a', 'l', ' ', 'B', 'u', 's', 'i', 'n', 'e', 's', 's', ' ', 'M', 'a', 'c', 'h', 'i', 'n', 'e', ' ', 'C', 'o', 'r', 'p', 'o', 'r', 'a', 't', 'i', 'o', 'n', '.']

use join:

''.join(this_is_a_list)

extended:

in case you plan to use the string in the future: This method is extremely inefficient, but I’m going to leave it here as a showcase of what not to do: (Thanks to @PM 2Ring)

# BAD EXAMPLE, AVOID THIS METHOD
final_word = ""
for i in xrange(len(this_is_a_list)):
    final_word = final_word + this_is_a_list[i]

print final_word

further edited, thanks to @kuro

final_word = ''.join(this_is_a_list)

2

solved How to print a list without [ , ” in python