L = [1,2,3]
M = ['a', 'b', 'c']
N = [1, 'a', 2, [32, 64]]

"""
Explanation: Chapter 10
Lists
A sequence of elements of any type.
End of explanation
"""


S = 'abc'
#S[1] = 'z' # <== Doesn't work!
L = ['a', 'b', 'c']
L[1] = 'z'
print L

"""
Explanation: Lists are mutable while strings are immutable. We can never change a string, only reassign it to something else.
End of explanation
"""


a = 23
b = 23
a is b

list1 = [1,2,3]
list2 = [1,2,3]
list1 is list2

"""
Explanation: Some common list procedures:
reduce
Convert a sequence (eg list) into a single element. Examples: sum, mean
map
Apply some function to each element of a sequence. Examples: making every element in a list positive, capitalizing all elements of a list
filter
Selecting some elements of a sequence according to some condition. Examples: selecting only positive numbers from a list, selecting only elements of a list of strings that have length greater than 10.
Everything in Python is an object. Think of an object as the underlying data. Objects have individuality. For example,
End of explanation
"""


list2 = list1
list1 is list2

"""
Explanation: list1 and list2 are equivalent (same values) but not identical (same object). In order to make these two lists identical we can alias the object.
End of explanation
"""


list1[0] = 1234
print list1
print list2

Back to the strings,

b = 'abc'
a = b
a is b

"""
Explanation: Now both names/variables point at the same object (reference the same object).
End of explanation
"""


a = 'xyz'
print a
print b

"""
Explanation: Let's try to change b by assigning to a (they reference the same object after all)
End of explanation
"""


a is b

id(b)

"""
Explanation: What happened is that we have reassigned a to a new object, that is they no longer point at the same object.
End of explanation
"""


