Notes (doing things in Python)--variables (lists, tuples)

Source: Internet
Author: User
  1. List: slices, indexes, references
  2. Build list: a=[1,2,3]
  3. references:a_ref=a, and a point to the same address
  4. List common actions:copy operation b=a[:]
  5. A.append(3): Add an element after list a
  6. A.insert(1, 20): Inserts 20 into the 1 position of List A
  7. A.pop(): pops up the last element of the list
  8. A.sort (): Sort the list
  9. A.reverse(): Anti-sorting the list
  10. del a[1]: Remove the first element of the list
  11. Nested, multiple types coexist into a list, such as c=[1,2, ' 123 ', ' ABC ']
  12. A.count (x):A contains the number of X (count on an element)
  13. Tuples: Equivalent to immutable lists, defined with (), equivalent to constants, can only be accessed not modified in situ
  14. Common operations: Have index, Count method, can be nested variable list (deprecated), tuple () can convert a list to a tuple

Notes (doing things in Python)--variables (lists, tuples)

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.