Tuples
# Good data type to use when the data is fixed and its not going to change
# Define a tuple
tuple_items = ("item1", "item2", "item3")
tuple_numbers = ("1", "2", "3")
# Check if items exist in a tuple
print("item2" in tuple_items)
# Check index of item in tuple
print(tuple_items.index("item2"))
# Check length of tuple
print(len(tuple_items))
# Index slices
print(tuple_items[0:2])
Last updated