In Python 3 you can do:
print(*words_list)
because print is just a function and the *
operator in this context will unpack elements of your list and put them as positional arguments of the function call.
In older versions you'd need to concatenate (join) elements of the array first, possibly converting them to strings, if they are not strings already. This can be done like this:
print ' '.join([str(w) for w in words_list])
or, more succinctly, using generator expression instead of list comprehension:
print ' '.join(str(w) for w in words_list)
Yet another alternative is to use the map
function, which results in even shorter code:
print ' '.join(map(str, words_list))
However, if you are on Python 2.6+ but not on Python 3, you can get print as a function by importing it from the future:
from __future__ import print_function
print(*words_list)