How do I clone a list so that it doesn't change unexpectedly after assignment? I would say the csv library is the only sensible option here, as it was built to cope with all csv use cases such as commas in a string, etc. enjoy another stunning sunset 'over' a glass of assyrtiko. How a top-ranked engineering school reimagined CS curriculum (Ep. And if the list contains non-string types (such as integers, floats, bools, None) then do: Why the map/lambda magic? I'm guessing plenty has changed with Python since then. python - Transform comma separated string into a list but ignore comma Use the StringIO Module to Convert a List to a Comma-Separated String in Python. Converting a list into comma-separated string with "and" before the last item - Python 2.7. This is a perfectly valid answer. List<String> to String - Join to a comma and quotes What are you trying to achieve by building this string? Site design / logo 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA. Cautionary note: this could potentially be dangerous if any of the strings inside list has a comma in between. How do I break a string in YAML over multiple lines? How to convert list into string with quotes in python Ask Question Asked 10 years ago Modified 1 year ago Viewed 24k times 8 i have a list and want it as a string with quotes mylist = [1,2,3] require O/P as myString = "'1','2','3'" i tried mystring = '\',\''.join (mylist) it gave me result as mystring = "1','2','3" '*len(record_hash)), record_hash). I have two stored sting variable I need to concat into a different variable for an api get request. How about saving the world? In Python 3, it was stored in the io module.. We can use the csv.writerow() function to write the list as a comma-separated row for a CSV file in the StringIO object. Python - Convert String to List - AskPython My phone's touchscreen is damaged. Are double and single quotes interchangeable in JavaScript? The most versatile is the list, which can be written as a list of comma-separated values (items) between square brackets. 3. An Informal Introduction to Python Making statements based on opinion; back them up with references or personal experience. You may run into such problem while dealing with scraped data stored as Pandas DataFrame. @SerialDownvoter: Can you please respond on posts that you downvote? Not the answer you're looking for? Generic Doubly-Linked-Lists C implementation. How about you just take the result of your computation, and add single quotes around it as a second step: How to convert list into string with quotes in python.