Python Learn list of days add, modify, delete operation method

Source: Internet
Author: User

In an ordered list of data, set the various data types, you can add elements to the list, you can also modify the elements inside the list, you can delete the elements inside the list, append (), insert (), remove (), pop (), and Global del Delete.

1, List added

N1=[' A ', ' B ', ' C ']

N1.append (' d ')

Append append, add an element to the list at the end

Insert () insertion means that you can add an element to any location, using insert (0, ' BB ')

2, List modification

n2=[1,2,3,4]

n2[0]=2

How to re-assign a value using subscript index

3, deleting elements

n3=["www.96net.com.cn", ' www.dc3688.com ', ' www.baidu.com ']

N3.pop ()

N3.remove ("www.baidu.com")

DEL N3[0]

In summary list of common operating methods to remember, be sure to do hands-on exercises

Article reprint (JIU le network http://www.96net.com.cn/)

Python Learn list of days add, modify, delete operation method

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.