Python notes Two

Source: Internet
Author: User

List Learning----------list:append tail insertion----------
name_list = ["alex","tony","eirc"]name_list.append(‘seven‘)name_list.append(‘moon‘)print(name_list)
----------List:insert Insert----------by position
name_list = ["alex","tony","eirc"]name_list.insert(2,‘pepole‘)print(name_list)
----------list:extend String Extension----------
name_list = ["alex","tony","eirc"]temp = [11,22,33,44]name_list.extend(temp)print(name_list)
----------the number of occurrences of the List:count element----------
name_list = ["alex","tony","eirc"]print(name_list.count(‘tony‘))
----------List:index Find the index position of an element----------
name_list = ["alex","tony","eirc"]print(name_list.index(‘alex‘))
----------List:p op removes the last element from the original list and assigns it to another variable----------
name_list = ["alex","tony","eirc"]x = name_list.pop()print(name_list)print(x)
----------List:remove Remove an element----------
name_list = ["alex","tony","eirc"]name_list.remove(‘alex‘)print(name_list)
----------List: element Delete, deletes the specified index location----------
name_list = ["alex","tony","eirc"]del name_list[1:3]print(name_list)

Python notes Two

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.