[Python] collections of data

04 Apr
April 4, 2021

1. List items are ordered, changeable, and allow duplicate values.

mylist = ["apple", "banana", "cherry"]

2. Tuple items are ordered, unchangeable, and allow duplicate values.

mytuple = ("apple", "banana", "cherry")

3. Set items are unordered, unchangeable, and do not allow duplicate values.

myset = {"apple", "banana", "cherry"}

4. A dictionary is a collection which is ordered*, changeable and does not allow duplicates.

thisdict = {
  "brand": "Ford",
  "model": "Mustang",
  "year": 1964

Noted: *As of Python version 3.7, dictionaries are ordered. In Python 3.6 and earlier, dictionaries are unordered.

Tags: ,
0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

© Copyright - HHGG It's 42