Lists, Tuples, Sets and Loops
Python has threem ain array types: Lists, tuples and sets.
Lists are similar to arrays in other languages. They are mutable, can contain duplicate items. Declare them using the square brace syntax:
cats = [‘Miow’, ‘Daisy’, ‘Malcolm’]
Tuples are immutable arrays. They can also contain duplicate values. Once declared they can never be changed. This makes them a bit faster than lists, so you might want to consider using them if you can. Declare then using the round brace syntax:
cat_types = (‘ginger’, ‘tabby’, ‘shorthair blue’)
Sets are even more restrictive. A set
They are fully polymorphinc, you can store any combination of types in there