How to remove [] from a list in python

爱喝马黛茶的安东尼
Release: 2019-06-24 17:21:53
Original
22227 people have browsed it

How to remove [] from a list in python

#How to remove [] from a list in python? Let me explain the specific method below:

LIST = ['Python','problem','whatever']
print(LIST)
Copy after login

Running results:

[Python, problem, whatever]
Copy after login

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
Copy after login

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'}
Copy after login

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!