Course Eleven - Use Lists in Python language

Use Lists in Python language By ienex Lists are one of the most versatile sequence data types in Python. Each element in a list has a position or index , starting from 0. Python supports several sequence types, but lists and tuples are the most commonly used. Creating Lists A list is created by placing comma-separated values inside square brackets [] . List items do not have to be of the same type : list1 = ['physics', 'chemistry', 1997, 2000] list2 = [1, 2, 3, 4, 5] list3 = ["a", "b", "c", "d"] Accessing List Elements Use square brackets to access elements by their index or a slice of the list: list1 = ['physics', 'chemistry', 1997, 2000] list2 = [1, 2, 3, 4, 5, 6, 7] print("list1[0]:", list1[0]) print("list2[1:5]:", list2[1:5]) Output: list1[0]: physics list2[1:5]: [2, 3, 4, 5] Updating List Elements You can update a single element or a slice of elements . To add new it...