Use str.join
:
>>> sentence = ['this', 'is', 'a', 'sentence'] >>> '-'.join(sentence) 'this-is-a-sentence' >>> ' '.join(sentence) 'this is a sentence'
Related Posts:
- How to convert list to string [duplicate]
- How do I concatenate two lists in Python?
- Why is it string.join(list) instead of list.join(string)?
- Why is it string.join(list) instead of list.join(string)?
- How do I concatenate two lists in Python?
- How do I concatenate two lists in Python?
- How can I concatenate str and int objects?
- Python: Get the first character of the first string in a list?
- AttributeError: ‘list’ object has no attribute ‘replace’ when trying to remove character
- How to check if a string is a substring of items in a list of strings?
- AttributeError: ‘list’ object has no attribute ‘replace’ when trying to remove character
- AttributeError: ‘list’ object has no attribute ‘replace’ when trying to remove character
- How do I check if there are duplicates in a flat list?
- Create nice column output in python
- How does str(list) work?
- Python cant convert ‘list’ object to str error [closed]
- Cannot concatenate ‘str’ and ‘float’ objects?
- Python – TypeError: ‘int’ object is not iterable
- TypeError: list indices must be integers or slices, not str
- Does Python have a string ‘contains’ substring method?
- IndexError: list index out of range and python
- TypeError: a bytes-like object is required, not ‘str’ when writing to a file in Python3
- Finding the index of an item in a list
- Accessing the index in ‘for’ loops?
- Best way to convert string to bytes in Python 3?
- Pythonic way to create a long multi-line string
- Does Python have a string ‘contains’ substring method?
- What does the list() function do in Python?
- TypeError: not all arguments converted during string formatting python
- Is there a short contains function for lists?
- How do I append one string to another in Python?
- appending list but error ‘NoneType’ object has no attribute ‘append’
- Random string generation with upper case letters and digits
- Check if something is (not) in a list in Python
- How to avoid “RuntimeError: dictionary changed size during iteration” error?
- How to read a text file into a string variable and strip newlines?
- How can I randomly select an item from a list?
- Fastest way to check if a value exists in a list
- How can I count the occurrences of a list item?
- TypeError: ‘list’ object cannot be interpreted as an integer
- Split a string into 2 in Python
- Best way to strip punctuation from a string
- Get list from pandas dataframe column or row?
- Finding and replacing elements in a list
- ValueError: max() arg is an empty sequence
- Remove list from list in Python
- Append integer to beginning of list in Python
- List comprehension on a nested list?
- Union of two lists in Python
- Python: Array v. List
- How do I check if a list is empty?
- Convert columns to string in Pandas
- How to delete a character from a string using Python
- Remove the first character of a string
- What’s the idiomatic syntax for prepending to a short python list?
- Converting Dictionary to List?
- How to deep copy a list?
- Alphabet range in Python
- How can I splice a string?
- Finding all possible permutations of a given string in python
- How do I check if a list is empty?
- IndexError: list index out of range and python
- Pop index out of range
- Print list without brackets in a single row
- How to convert string to binary?
- How to iterate through two lists in parallel?
- Converting from a string to boolean in Python?
- How to remove \n from a list element?
- how to create a list of lists
- Python assigning multiple variables to same value? list behavior
- How can I print variable and string on same line in Python?
- Append a tuple to a list – what’s the difference between two ways?
- Defining lists as global variables in Python
- Remove quotes from String in Python
- Convert hex string to int in Python
- How can I check if character in a string is a letter? (Python)
- How can I remove all instances of an element from a list in Python?
- Create an empty list in Python with certain size
- What’s the difference between lists enclosed by square brackets and parentheses in Python?
- Properly formatted multiplication table
- How to get a function name as a string?
- Appending to a list gives ‘int’ object has no attribute ‘append’
- Python data structure sort list alphabetically
- Python: Converting string into decimal number
- TypeError: unsupported format string passed to list.__format__
- How to compare individual characters in two strings in Python 3
- How to create a numpy array of lists?
- How to repeat a string with spaces?
- how to concatenate two dictionaries to create a new one in Python?
- How do I convert a string to a double in Python?
- How can I copy a Python string?
- How to get ° character in a string in python?
- numpy array concatenation error: 0-d arrays can’t be concatenated
- In Python, is there an elegant way to print a list in a custom format without explicit looping?
- Determine if 2 lists have the same elements, regardless of order? [duplicate]
- Mutable strings in Python
- Building a list inside a list in python
- Writing Python lists to columns in csv
- Python – difference between two strings
- TypeError: coercing to Unicode: need string or buffer