INFO1110 Lecture 4: 4 – Loops and lists
Document Summary
An array is a contiguous block of memory containing multiple values of the same type. A multi-element array is comma-separated objects of the same type within square brackets. Lists are objects that contain an array of objects containing memory addresses. So the length of each item is the length of addressable memory. They also contain metadata about the list, such as the length of the list. List size is not fixed, i. e. mutable: any type of object can be included, elements can be inserted or removed in any position, a subset of the list can be created from the list, very different memory structure. In python, there are only lists, no arrays. Accessing the last element of the array x[-1] x[len(x) - 1] # using a while loop: index = 0 while index < len(my_list): if my_list[index] == search_item: found = true break.