Python Data Type-List VI

Source: Internet
Author: User

This is the content of the December plan, beginning in January 2018 ~

If there is any mistake, please ask for it ~

A list is the most commonly used Python data type and can appear as a comma-separated value within a square bracket.

The list of data items does not need to have the same type, which is already handy.

To access the available subscript and slice methods

1 list=['a','b','C', 2print(list[0])3print(List[1:4])
a['b'c', 1]

Update, change directly, add element at the end. Append

1 list=['a','b','c' , to]2print(list[0])3 list[0]=14  Print(list[0])
1 list=['a','b','C', 2 list.append (6)3print(list[5])

Del statement to delete the elements of the list

1 list=['a','b','C', 2del list[2]3print(List)

Python Expressions Results Description
Len ([1, 2, 3]) 3 Length
[1, 2, 3] + [4, 5, 6] [1, 2, 3, 4, 5, 6] Combination
[' hi! '] * 4 [' hi! ', ' hi! ', ' hi! ', ' hi! '] Repeat
3 in [1, 2, 3] True Whether the element exists in the list
For x in [1, 2, 3]: print (x, end= "") 1 2 3 Iteration

In addition, its nesting and built-in functions are quite a lot of, later said

Python Data Type-List VI

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.