Python: Simple Method example for deleting the same element in the list, python example

Source: Internet
Author: User
Tags python list

Python: Simple Method example for deleting the same element in the list, python example

This example describes how to delete the same elements in the list in Python. We will share this with you for your reference. The details are as follows:

Removing repeated elements in the list is very simple and you can directly use the code:

A = [11, 21, 3, 4, 3, 2, 5] B = list (set (a) print (B)

Running result:

E: \ Program \ Python> d. py [11, 21, 3, 4, 3, 2, 5] [2, 3, 4, 5, 11, 21]

Have you seen it? The result does not contain repeated elements. However, at the same time, the elements in the results are sorted in ascending order!

PS: Here are several repeated tools for your reference:

Online deduplication tools:
Http://tools.jb51.net/code/quchong

Online text deduplication tool:
Http://tools.jb51.net/aideddesign/txt_quchong

For more Python-related content, refer to this topic: Python list) operation Skills summary, Python coding skills summary, Python data structure and algorithm tutorial, Python function usage skills summary, Python string operation skills summary, Python basic and advanced tutorial and Python file and directory operation tips

I hope this article will help you with Python programming.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.