Python:list, tuple, dict, set

Source: Internet
Author: User

A list is an ordered set of elements that can be added and removed at any time.

>>> s = ['python''java', ['asp ' ' PHP ' ' Scheme ' ]>>> s[2][1]'php'

Tuple is similar to list, but a tuple cannot be modified once initialized

>>> t = ($)>>> t[2]3

Dict, which is the map in Java, is stored using key-value (Key-value).

>>> d = {'Michael'Bob'Tracy ': >>>d['Michael']95

Set is similar to Dict and is a set of keys, but does not store value. Because key cannot be duplicated, there is no duplicate key in set.

To create a set, you need to provide a list as the input collection:

>>> s = Set ([1, 2, 3])>>> s{1, 2, 3}

Python:list, tuple, dict, set

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.