It is already a list:

>>> type(my_set)
<class 'list'>

Do you want something like:

>>> my_set = set([1, 2, 3, 4])
>>> my_list = list(my_set)
>>> print(my_list)
[1, 2, 3, 4]

EDIT: Output of your last comment:

>>> my_list = [1,2,3,4]
>>> my_set = set(my_list)
>>> my_new_list = list(my_set)
>>> print(my_new_list)
[1, 2, 3, 4]

I'm wondering if you did something like this:

>>> set = set()
>>> set([1, 2])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'set' object is not callable
Answer from user on Stack Overflow
🌐
WebUtility
webutility.io › home › text to list converter / split text into new lines
Text to List Converter / Split Text into New Lines - WebUtility.io
February 28, 2025 - If you want the prefix as the number range (list) then select the “Number Range” value from the drop-down. Then click on the “Convert” button to split the text into new lines as a list.
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-convert-set-into-a-list
Convert set into a list in Python - GeeksforGeeks
In this case, the identity function (lambda x: x) can be used to map each element from the set to a list. ... Explanation: Although this method is not as commonly used for simple conversions, it demonstrates how map() can be employed in this context. We can convert a set to a list by creating a shallow copy of the set, although this approach is rarely used directly for set-to-list conversion.
Published: July 11, 2025
Discussions

How to convert a set to a list in python? - Stack Overflow
Copylist = set([1,2,3,4]) # oops ... = list(my_set) ... CopyTraceback (most recent call last): File "", line 1, in TypeError: 'set' object is not callable ... Save this answer. ... Show activity on this post. Whenever you are stuck in such type of problems, try to find the datatype of the element you want to convert first by ... More on stackoverflow.com
🌐 stackoverflow.com
java - How to Convert List<String> to List<Object> - Stack Overflow
I want to convert List to List . One of the existing methods is returning List and I want to convert it to List . Is there a direct way in Java More on stackoverflow.com
🌐 stackoverflow.com
converting a string that is list-like into a list
Since your input isn't actually valid JSON or Python syntax, it won't work with AST or JSON. You need a custom parser. Fortunately, there is a library called PyParsing that can make quick work. In [2]: import pyparsing as pp ...: ...: LBRACK,RBRACK,COMMA = map(pp.Suppress,"[],") ...: ...: key_value = pp.Group(LBRACK + pp.Word(pp.alphas) + COMMA + pp.Word(pp.nums) + RBRACK + pp.Optional(COMMA)) ...: ...: parser = LBRACK + pp.OneOrMore(key_value) + pp.Optional(COMMA) + RBRACK ...: ...: print(parser.parseString("[[c,1],[a,1],[b,2]]")) ...: print(parser.parseString("[[c,1]]")) [['c', '1'], ['a', '1'], ['b', '2']] [['c', '1']] More on reddit.com
🌐 r/learnpython
30
1
July 11, 2022
python - How to convert string representation of list to a list - Stack Overflow
I was wondering what the simplest way is to convert a string representation of a list like the following to a list: x = '[ "A","B","C" , " D"]' Even in cases More on stackoverflow.com
🌐 stackoverflow.com
🌐
Pluralsight
pluralsight.com › blog › software development
6 Best Methods for Python String to List Conversion | Pluralsight
That is, string_list = [“plural”, “sight”, “python”]. The split() method is used to convert a string to a list based on a delimiter.
🌐
Convert Town
convert.town › column-to-comma-separated-list
Convert Column to Comma Separated List Online
Convert column of data to comma separated list of data instantly using this free online tool.
🌐
Tutorialspoint
tutorialspoint.com › python › list_list.htm
Python List list() Method
aTuple = (123, 'xyz', 'zara', 'abc') aList = list(aTuple) print("List elements : ", aList) When we run above program, it produces following result − ... We can also convert a string into a list where the characters in the string become separate elements of the list.
🌐
DigitalOcean
digitalocean.com › community › tutorials › python-convert-string-to-list
How To Convert a String to a List in Python | DigitalOcean
Convert strings to lists in Python using split(), list(), json.loads(), and more. Complete guide with examples for various string formats and use cases.
Find elsewhere
🌐
freeCodeCamp
freecodecamp.org › news › python-string-to-array-how-to-convert-text-to-a-list
Python String to Array – How to Convert Text to a List
February 21, 2022 - The most straightforward way is to type cast the string into a list. Tyepcasting means to directly convert from one data type to another – in this case from the string data type to the list data type.
🌐
IT Tools
it-tools.tech › list-converter
List converter - IT Tools
This tool can process column-based data and apply various changes (transpose, add prefix and suffix, reverse list, sort list, lowercase values, truncate values) to each row. Trim list items · Remove duplicates · Convert to lowercase · Keep line breaks · Sort list · Sort alphabetically ·
🌐
GeeksforGeeks
geeksforgeeks.org › python-program-convert-string-list
Convert string to a list in Python - GeeksforGeeks
If we want to break down a string into list of individual characters then we can use list() function which is a simple and effective method. This approach adds each character of the string as an element in a list.
Published: May 5, 2025
🌐
Analytics Vidhya
analyticsvidhya.com › home › 5 ways to convert string to a list in python
5 Ways to Convert String to a List in Python - Analytics Vidhya
April 22, 2025 - One popular method for converting a string to a list in Python is using the list() constructor. This constructor takes an iterable, such as a string, and converts it into a list by considering each character as a separate element.
🌐
AskPython
askpython.com › python › string › convert-string-to-list-in-python
Convert String to List in Python - AskPython
January 16, 2024 - What if we need a list of characters present in a string? In that case, direct type conversion from string to list in Python using the list() method does the
🌐
Reddit
reddit.com › r/learnpython › converting a string that is list-like into a list
r/learnpython on Reddit: converting a string that is list-like into a list
July 11, 2022 -

Hopefully I can explain this properly. I have no control over how the input string which is kind of formatted like a list of lists but without quotes (so I can't use json.loads)

Example input (I'm reading it in using sys.argv):

"[[a,1],[b,2]]"

I'd like to convert this to be a real list of lists so I can iterate through them in my script.

I can get what I need using split but I was wondering if there was a better way to do it. Either a better way to divide them or a way to add quotes - whatever works.

import sys

try1 = sys.argv[1]
lst1 = try1.split("],")
print("try #1 (works but could be better?)")
print(len(lst1))
for item in lst1:
    print(item.lstrip("[[").rstrip("]]"))

# doesn't work - 1 item in the list
print("\n\nTry #2")
try2 = sys.argv[1:]
print(len(try2))

# doesn't work - length of 13
print("\n\nTry #3")
print(len(list(sys.argv[1])))

Output

$ python3 t.py "[[a,1],[b,2]]"
try #1 (works but could be better?)
2
a,1
b,2


Try #2
1


Try #3
13

Thanks for reading

🌐
GeeksforGeeks
geeksforgeeks.org › python-convert-list-into-list-of-lists
Python | Convert list into list of lists - GeeksforGeeks
May 8, 2023 - Create a new list named lst with the elements 'alice', 'bob', and 'cara'. Call the convert_to_list_of_lists function with the lst list as an argument and store the resulting list in a variable named res.
🌐
DigitalOcean
digitalocean.com › community › tutorials › set-to-list-in-java
How to Convert a Set to a List in Java: Simple and Efficient Methods | DigitalOcean
April 20, 2025 - Learn how to convert a Set to a List in Java using methods like constructors, streams, and loops. Includes code examples, performance tips, and use cases.
🌐
Reddit
reddit.com › r/learnpython › convert list thats a string back to a list?
r/learnpython on Reddit: convert list thats a string back to a list?
March 11, 2024 -

This is a weird one but I have an output from a csv that is a list but one reading it from the list it becomes a string and I want to to convert that back into a list, any ideas?

"ingredients": "['asparagus', 'olive oil', 'salt', 'unsalted butter', 'sage leaves', 'fresh lemon juice', 'lemon, zest of', 'parmigiano-reggiano cheese']",

🌐
FavTutor
favtutor.com › blogs › set-to-list-python
5 Ways to Convert Set to List in Python | FavTutor
September 26, 2021 - Python supports many in-built functions ... convert the python set into the list data type. You have to pass the python set inside the list() function as an argument, and the output will be the list of the same elements...