Home >Backend Development >Python Tutorial >How to remove parentheses from a list in python
You can use list parsing to remove the parentheses of the list. The specific method is to convert the result of list comprehension into a new list.
For example, suppose there is a list:
my_list = [1, 2, 3, 4, 5]
You can use list parsing to remove the parentheses of the list:
new_list = [item for item in my_list]
In this way, new_list
is the list without the brackets:
print(new_list)# 输出:[1, 2, 3, 4, 5]
The above is the detailed content of How to remove parentheses from a list in python. For more information, please follow other related articles on the PHP Chinese website!