Computer Science 1026A/B Chapter Notes - Chapter 6: John Q., Concatenation, Substring
terubarenuka and 39895 others unlocked
26
COMPSCI 1026A/B Full Course Notes
Verified Note
26 documents
Document Summary
Lists are the fundamental mechanism in python for collecting multiple value. It is a container that stores a sequence of values. Here we created list and specify the initial values that are to be stored in the new list. The square brackets indicate that we are creating a list. 6. 1. 2: accessing list elements: a list is a sequence of the elements, each of which has an integer position or index. To access a list element, you specify which index, i, you want to use, using the notation list[i: a. there are two difference between lists and strings. Lists can hold values of any type, whereas strings are sequences of characters. b. Moreover strings are immutable- you cannot change the characters in the sequence. You replace one list element with another, like this: values [5] = 87. You can use the len function to obtain the length of the list, that is, the number of the elements.