# Create a list my_list = ["dog", "cat", "turtle"] print("This is the list: ") print(my_list) print("This is the first element: ") try: print(my_list[5]) except IndexError: print("The index is out of range!!!") print("This is the last element: ") print(my_list[-2]) print("This is the size of the list: ") size = len(my_list) print(size) my_list[2] = "new turtle" print("This is the list: ") print(my_list) if "dog" in my_list: print("Yeah ... I have a dog.") my_list.append("snake") print("This is the list: ") print(my_list) print("The cat position is: ") print(my_list.index("cat")) print("The sorted list is: ") my_list.sort(reverse=True) print(my_list) # print("The max item in the list is: ") x = max(my_list) print(x) ################ # Copy the list ################ my_list1 = my_list my_list2 = my_list1 # my_list2[2] = "lion" print("The lists are the following") print(my_list) print(my_list1) print(my_list2) # my_list3=[] for x in my_list: my_list3.append(x) my_list3[2] = "mouse" print("The lists are the following") print(my_list) print(my_list1) print(my_list2) print(my_list3) my_list4 = [] my_list4 += my_list my_list4[2] = "elephant" print("The lists are the following") print(my_list) print(my_list4) ######### # 2D ######### # my_2d_list = [("dog", 1), ("cat", 3), ("turtle", 4)] print("This is the 2d list: ") print(my_2d_list) t = ("mouse", 2) my_2d_list[0] = t print(my_2d_list)