Q: Python function for joining sentences in a list I have the requirement of joining all the words using underscore.
Input
test = ["Hello", "World", "Test me"]

Output
"Hello_World_Test_me"

What is the best way to achieve this in python3 ?

A: "_".join(w for word in test for w in word.split())

python string's join method joins the provided list with the string on which it is called upon.

A: You can join the array using '_'.join(list) and then replace space with _
test = ["Hello", "World", "Test me"]

res = '_'.join(test).replace(' ', '_')
print(res)

Thank you
