This has always confused me. It seems like this would be nicer:
my_list = ["Hello", "world"]
print(my_list.join("-"))
# Produce: "Hello-world"
Than this:
my_list = ["Hello", "world"]
print("-".join(my_list))
# Produce: "Hello-world"
Is there a specific …
Is there a simpler way to concatenate string items in a list into a single string? Can I use the str.join() function?
E.g. this is the input ['this','is','a','sentence'] and this is the desired output this-is-a-sentence
…
I want to remove all empty strings from a list of strings in python.
My idea looks like this:
while '' in str_list:
str_list.remove('')
Is there any more pythonic way to do this?