# a list of strings fruits = ["apple", "orange", "tomato", "banana"] fruits[2] # indexing a list len(fruits) # the length of a list
# a list with integers # Syntax : range(start point, end point, step size) nums = list(range(0, 30, 5)) print(nums) # -> [0, 5, 10, 15, 20, 25] The end point is not included
# Slicing lists # Syntax: List[start point : end point : step size ] nums2 = list(range(0, 100, 5)) print(nums) print(nums2[1:5:2]) # get from item 1(starting point) through item 5(end point, not included) with step size 2 print(nums2[0:3]) # get items 0 through 3 print(nums2[4:]) # get items 4 onwards print(nums2[-1]) # get the last item print(nums2[::-1]) # get the whole list backwards