Tuples
peanuts = ['charlie', 'snoopy', 'linus', 'schroeder']
# We can swap out linus for lucy like this:
peanuts[2] = 'lucy'
peanuts # ['charlie', 'snoopy', 'lucy', 'schroeder']# For tuples, we use normal brackets as opposed to square brackets
coordinate1 = (1, 2, 3)
# As with lists, you must separate each value by a comma
mixed_tuple = (True, 'chris gayle', (4,4))
# Tuples can store mixed values, and even tuples!
# You access data from a tuple the same way you access them from a list
mixed_tuple[0] # True
# Yes, the index also starts at 0
mixed_tuple[2][1] # 4coordinate1[1] = 26 # (1, 26, 3) right? Nope...Exercises
Last updated