Python List Dictionary tuple

Source: Internet
Author: User

List

The 1 list consists of a series of elements arranged in a particular order. In Python, the square brackets [] are used to delimit the elements in a comma.

2 Access list element------Index (ordered collection)

Output Result:

3 modifying, adding and deleting elements

Modify:

Output Result:

Add to:

      

Output Result:

      

Append (the element is added by default at the end of the list), and there is an arbitrary insertion element insert

      

Output Result:

      

Delete (there are three types)

A; Know list index Del

      

Output Result:

      

B: Do not know where the element is in the list, and know the element value to remove:

      

Output Result:

      

C; Remove the end of list element pop

      

Output Result:

      

Pop there's another way of knowing the list index

      

Output Result:

      

Can be summed up in four words: increase, delete, change, plug

4 List of Actions

Traverse the entire list:

      

Output Result:

        

List slices (Gu Tou regardless of tail):

      

Output Result:

Slices can also traverse:

       

Output Result:

      

5 List Length:

      

Output Result:

      

6 Use the method sort () to sort the list in a permanent order:

      

Output Result:

      

Use the method sort () to sort the list temporarily

      

Output Result:

      

Reverse the Print List:

      

Output Result:

      

Index

Output Result:

       

 

 

      

Python List Dictionary tuple

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.