CS 1110 Lecture Notes - Lecture 12: Call Stack, Precondition
Document Summary
10/1/15 -- lesson 12 -- lists and sequences. Once python runs into an error, it will slowly erase call stacks, one at a time, in attempt to recover from the error. Once the entire call stack is empty, then python crashes. Access values with [] x[0] is 5 x[6] causes an error x[0:2] is [5,6] (excludes other values) Error if the value is not there x. index(9) would evaluate to 3. Returns number of times value appears in the list x. count(5) evaluates to 2. For instance, l = [5, 7. 8, true, "what up?"] Lists are in fact folders with ids just like objects. However, unlike objects, attributes in lists are indexed, not named. Lists are built into python and are therefore types, not classes. To call a value from the list, it must be of the form list_name[number] To call a value from an object, it must be of the form class. attribute. This is essentially what we mean by "object"