#How to remove [] from a list in python? Let me explain the specific method below:
LIST = ['Python','problem','whatever'] print(LIST)
Running results:
[Python, problem, whatever]
Related recommendations: "Python Video Tutorial"
If you want to start from Removing the square brackets from the output converts it to a string instead of printing the list directly:
>>> LIST = ['Python','php','java'] >>> print(", ".join(LIST)) Python, php, java
If the elements in the list are not strings, you can use repr (if you want to quote strings) or str (if not) convert them to strings like this:
>>> LIST = [1, "foo", 3.5, { "hello": "bye" }] >>> print(", ".join(repr(e) for e in LIST)) 1, 'foo', 3.5, {'hello': 'bye'}
The above is the detailed content of How to remove [] from a list in python. For more information, please follow other related articles on the PHP Chinese website!