Python mencantumkan Tuples Set Kamus

# list: mutable, can be indexed and sliced, repetitions allowed
l = [0, 1, 2.3, "hello"]
l[0]   >>> 0
l[-1]  >>> "hello"
l[1:2] >>> [1, 2.3]
# sets: as list, but repetions are rejected
s = {0, 2, 63, 5, 5} # the second 5 will be discarded
# tuple: can be indexed, immutable
t = (5, 6, 8, 3)
t[0] >>> 5
t[2] >>> 8
# dictionary: pairs key - value. 
# Types of keys and values must (or, for your sanity, should be) uniform type
# keys are unique
d1 = {"key1" : "value1", "key2" : "value2"}
d2 = {1 : "value1", 2 : "value2"}
d3 = {"key1" : 1, "key2" : 2}
print(d1["key1"]) >>> "value1"
print(d2[1])      >>> "value1"
print(d3["key1"]) >>> 1
wolf-like_hunter