-
Notifications
You must be signed in to change notification settings - Fork 0
Python Collections
Konstantin Schmidt edited this page Apr 28, 2019
·
2 revisions
- List is a collection which is ordered and changeable. Allows duplicate members. In Python lists are written with square brackets.
thislist = ["apple", "banana", "cherry"]
- Tuple is a collection which is ordered and unchangeable. Allows duplicate members. In Python tuples are written with round brackets.
thistuple = ("apple", "banana", "cherry")
- Set is a collection which is unordered and unindexed. No duplicate members. In Python sets are written with curly brackets. Sets are unordered, so the items will appear in a random order!
thisset = {"apple", "banana", "cherry"}
- Dictionary is a collection which is unordered, changeable and indexed. No duplicate members. In Python dictionaries are written with curly brackets, and they have keys and values.
thisdict = { "brand": "Ford", "model": "Mustang", "year": 1964 }
Build with ❤️