Order

Lists and tuples maintain order. Dictionaries and sets are unordered.

list = ["fish", "dog", "cat"]
tuple = ("fish", "dog", "cat")
dictionary = {
    'fish': 'Bubbles',
    'dog': 'Spot',
    'cat': 'Frisky',
}
set = {"fish", "dog", "cat"}

print("list:", list)
print("dictionary:", dictionary)
print("tuple:", tuple)
print("set:", set)


Output:

list: ['fish', 'dog', 'cat']
tuple: ('fish', 'dog', 'cat')
dictionary: {'dog': 'Spot', 'fish': 'Bubbles', 'cat': 'Frisky'}
set: {'dog', 'fish', 'cat'}

results matching ""

    No results matching ""