You could use a list comprehension or a generator expression instead:
', '.join([str(x) for x in list]) # list comprehension
', '.join(str(x) for x in list) # generator expression
More Related Contents:
- What does += mean in this context?
- Most efficient way to build single-element list from string with or without spaces? [closed]
- How to name a file using a value in a list in a dictionary?
- What does “list comprehension” and similar mean? How does it work and how can I use it?
- Why does append() always return None in Python? [duplicate]
- Convert all strings in a list to int
- Get unique values from a list in python [duplicate]
- Element-wise addition of 2 lists?
- Sum a list of numbers in Python
- List comprehension vs generator expression’s weird timeit results?
- Python copy a list of lists [duplicate]
- Calculating arithmetic mean (one type of average) in Python [duplicate]
- Modify a list while iterating
- How do I loop through a list by twos? [duplicate]
- converting a list of integers into range in python
- How to make a set of lists
- How can I find same values in a list and group together a new list?
- What’s the difference between lists enclosed by square brackets and parentheses in Python?
- Difference between using [] and list() in Python
- TypeError: ‘float’ object is not subscriptable
- Python .sort() not working as expected
- Fastest way to count number of occurrences in a Python list
- Creating a dictionary with list of lists in Python
- Mapping dictionary value to list
- Creating sublists [duplicate]
- Can’t sort my list because it is NoneType? Simple Python [duplicate]
- How to sort a list of dictionaries by a value of the dictionary in Python?
- Why Python `Memory Error` with list `append()` lots of RAM left
- How to change variables fed into a for loop in list form
- list extend() to index, inserting list elements not only to the end