Summary of [Python List Tuple]

Source: Internet
Author: User
Tags python list

The list created can have different types of values

>>> numbers=[1,2,'three','four','  Five']>>> numbers['three'  Four"Five"

Append () method

>>> numbers.append ('6')>>> numbers['  Three' four'Five' 6 ' ]

Pop () method

>>> Numbers.pop (3)'four'>>> numbers[' three ' ' Five ' ' 6 ' ]

Insert () method

>>> Numbers.insert (3,4)>>> numbers['three'  Five'6']

Access directly through indexed values

>>> numbers[2]=3>>> numbers['Five ' 6 ' ]

A tuple is a list of values that cannot be changed once the initialization is initialized

But a tuple can have a list as an element tuple cannot change the element address so even the list doesn't matter.

And the values in the list can change randomly.

Dict because if the key value can be hash, so it can not put the list and so on itself can change elements

Set is a set of unordered and non-repeating elements in mathematical sense

>>> S=set ([1,2,2,3,3,4,4,5,5,5])>>> sset ([1, 2, 3, 4, 5])>>> S.add (5)>>> sset ([1, 2, 3, 4, 5])>>> s.remove (5)>>> Sset ([1, 2, 3, 4])>>> s2 = set ([1,2,3,4,5])>>> s&s2set ([1 , 2, 3, 4])>>> s| S2set ([1, 2, 3, 4, 5])

Summary of [Python List Tuple]

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.