Your function prints your string to stdout, then returns the list itself unchanged.

Build a string and return that instead of printing:

def to_string(my_list):
    result = ''
    last = len(my_list) - 1
    for pos, elem in enumerate(my_list):
        result += str(elem)
        if pos != last:
            result += ', '
    return result

This loops over all elements, keeping a position counter with the enumerate() function; this way it's easy to detect if we are adding the last element to the result.

Answer from Martijn Pieters on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-program-to-convert-a-list-to-string
Python Program to Convert a List to String - GeeksforGeeks
May 8, 2026 - Converting a list into a string is a common task in Python. This can be done using methods like join(), loops, list comprehension and map() depending on the type of elements in the list.
Discussions

python - How to convert list to string - Stack Overflow
How can I convert a list to a string using Python? More on stackoverflow.com
🌐 stackoverflow.com
python - Convert a list to string without commas - Stack Overflow
Communities for your favorite technologies. Explore all Collectives · Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work More on stackoverflow.com
🌐 stackoverflow.com
Converting a lists of characters into a list of strings
50 votes, 36 comments. So, this *should* be a really, dead simple operation but it's been stumping me for hours today. How in the h-e-double… More on reddit.com
🌐 r/learnpython
36
50
December 19, 2022
how to convert a parameter list into a string in python without using the join function - Stack Overflow
I need to write a function which gets one parameter as a list with multipul values. the list needs to be converted into a string without using the join function. I'd love to use some help! thanks... More on stackoverflow.com
🌐 stackoverflow.com
🌐
StrataScratch
stratascratch.com › blog › python-list-manipulation-convert-lists-to-strings
Python List Manipulation: Convert Lists to Strings - StrataScratch
April 4, 2025 - Even writing to logs or debug outputs becomes cleaner when you format lists as strings. So whether you’re building a user interface, exporting data, or just tidying up console output, this conversion step becomes surprisingly essential. It’s a tiny transformation that unlocks big compatibility and clarity across your codebase, like all other Python list methods, including Python add to list. There are several ways to turn a list into a string, and your choice often depends on what's in the list and how you want the result to look.
🌐
DataCamp
datacamp.com › tutorial › how-to-convert-a-list-to-a-string-in-python
How to Convert a List to a String in Python | DataCamp
April 12, 2024 - In Python, converting a list to a string can mean converting each element into a string or turning the entire list into one string.
🌐
Simplilearn
simplilearn.com › home › resources › software development › how to convert a list to string in python easily [2026]
How to Convert a List to String in Python Easily [2026]
August 23, 2026 - Learn the fastest, cleanest ways to convert a Python list to a string using join(), map(), list comprehension, and more, with copy-paste code examples.
Address: 5851 Legacy Circle, 6th Floor, Plano, TX 75024 United States
Find elsewhere
🌐
Reddit
reddit.com › r/learnpython › converting a lists of characters into a list of strings
r/learnpython on Reddit: Converting a lists of characters into a list of strings
December 19, 2022 - I did post above. But, ultimately, without the repetition of use, the fact that both join and split work on strings, but 180 degrees from one another.
🌐
Quora
quora.com › How-do-I-convert-a-list-into-a-string-in-python
How to convert a list into a string in python - Quora
Answer (1 of 6): There are four ways to convert a List into a String in Python. They are: Method #1 : Iterate over the list, adding elements to some empty string at every index. Code Example: my_list = ['Code', 'for', 'Us'] #initialize an empty string my_string = "" #traverse in the string ...
🌐
Stack Overflow
stackoverflow.com › questions › 47251005 › how-to-convert-a-parameter-list-into-a-string-in-python-without-using-the-join-f
how to convert a parameter list into a string in python without using the join function - Stack Overflow
I need to write a function which gets one parameter as a list with multipul values. the list needs to be converted into a string without using the join function. I'd love to use some help! ... What have you already tried? This is too broad of a question as is. ... In which language?. Try to write some codes that u have tried. ... The language is Python.
🌐
Facebook
facebook.com › pybeginner › posts › convert-a-list-to-a-string-in-pythonpythonstrings-listtostring-codingtips › 1497545169080190
Convert a List to a String in Python #PythonStrings ...
Explore the things you love · Log in to Facebook · English (UK) · Русский · Українська · Suomi · 中文(简体) · Deutsch · العربية · More languages…
🌐
Flexiple
flexiple.com › python › convert-list-to-string-python
Convert list to string in Python - 3 easy ways - Flexiple Tutorial - Flexiple
March 10, 2022 - By using the str() function which converts objects to a string we can convert the int values into a string before using the join method. Code to convert python list to string using map():
🌐
FavTutor
favtutor.com › blogs › list-to-string-python
Convert List to String in Python: 7 Best Methods (with code)
June 8, 2023 - Learn different methods for how to convert a list to a string in Python with examples. This includes list comprehension, join, and map functions.
🌐
Quora
quora.com › In-Python-how-do-you-convert-a-list-to-a-string
In Python, how do you convert a list to a string? - Quora
Answer (1 of 24): More details are needed to be able to answer this properly - there are too many unknowns. What should the string look like? What are the list elements? Are they strings, dictionaries, something else? A very simple case may be that you have a simple list of strings: [code]input...
🌐
Reddit
reddit.com › r/learnpython › how to convert list to string without brackets or spaces?
r/learnpython on Reddit: How to convert list to string without brackets or spaces?
May 3, 2017 -

This seems like it has a simple solution but I can't seem to find it. I have a list

test = [1, 2, 3, 4]

and I want to convert it to the string and remove the brackets and spaces

1,2,3,4

I've found that I can print the list correctly by using

print(*test, sep=',')

but I want to concatenate the string for use elsewhere, not just print it.

Any ideas?

🌐
OneUptime
oneuptime.com › home › blog › how to convert list to string in python
How to Convert List to String in Python
January 25, 2026 - Investigates incidents with AI and turns findings into fix pull requests for your review. ... Learn multiple ways to convert Python lists to strings, including join(), map(), list comprehensions, and handling mixed-type lists.
🌐
Great Learning
mygreatlearning.com › blog › it/software development › how to convert list to string in python
How to convert List to String in Python
November 7, 2024 - While the join() method is the simplest way to convert a list into a string, it only works if all the items in your list are already strings. This highlights the importance of understanding 'data types'—one of the first things every new coder should learn. If you want a gentle, hands-on introduction to these core concepts, our Free Python Course offers a clear roadmap.
🌐
Pluralsight
pluralsight.com › blog › software development
6 Best Methods for Python String to List Conversion | Pluralsight
As strings and lists are two of the most popular data types in Python, it’s likely you’ll come across situations where you need to convert a list to a string (or vice versa) so you can access and apply functionality specific to those data types. In this tutorial, I’ll show you six tried-and-true methods to convert strings into lists in Python.
🌐
SPEC INDIA
spec-india.com › blog › python-list-to-string
Python List to String Conversion: Easy Methods & Examples
October 28, 2024 - There will be many situations where developers need to convert a list to a string python such as writing list items to a text file, CSV file, or command line. To do so, there are four ways to turn a list into a string Python