Skip to content

Latest commit

 

History

History
31 lines (21 loc) · 622 Bytes

DataTypes.md

File metadata and controls

31 lines (21 loc) · 622 Bytes

Other data structures

See the Python docs page for more info

Tuple

A tuple consists of an immutable number of values separated by commas

t = () # empty tuple
t = 1, 2, 3

Set

A set is an unordered collection with no duplicate elements

s = set() # empty set
s = {1, 2, 3, 4}

Dictionary

A dictionary is a set of key: value pairs, with the requirement that keys are unique

d = {} # empty dict
d = {1: 'one', 2: 'two', 3: 'three'}
d[4] = 'four' # assigns the value 'four' to the key 4