python join list to string

>>> sentence = ['this','is','a','sentence']
>>> '-'.join(sentence)
'this-is-a-sentence'

Here is what the above code is Doing:
1. We create a list of strings called sentence.
2. We use the join() method to concatenate the strings in the list, using a hyphen as the separator.
3. We print the resulting string.

The join() method is useful when you have a list of strings that need to be joined together into a single string value.

The join() method is called on a string, gets passed a list of strings, and returns a string.

The returned string is the concatenation of each string in the passed-in list.

The string on which the join() method is called is used as the separator between each string from the passed-in list.

If you don’t pass anything into the join() method, a blank string is used as the separator.

You can use any character or characters as the separator.

You can also pass in a list of characters and join() will use the characters as the separator.

You can use the + operator to concatenate strings, but it’s not as efficient as the join() method.

The join() method is faster than using the + operator to concatenate strings.

The + operator requires creating a new string object for each concatenation, which takes up a lot of memory and is slow.

The join() method reuses a single string object, which is much more efficient.

The join() method can be used to concatenate any iterable, not just lists of strings.

The join() method is often used to read data from a file one line at a time.

The join() method is also useful for building up strings from a sequence of partial strings.

The join() method can be used to convert a list of integers into a string.

The join() method can be used to convert a list of floats into a string.

The join() method can be used to convert a list of tuples into a string.

The join() method can be used to convert a list of dictionaries into a string.

The join() method can be used to convert a list of lists into a string.

The join() method can be used to convert a list of sets into a string.

The join() method can be used to convert a list of objects into a string.