Tag Archive for: data collection

[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.

© Copyright - HHGG It's 42