Open main menu

CDOT Wiki β

Changes

OPS435 Python Lab 3

8 bytes added, 09:41, 3 June 2017
PART 2 - Manipulating Items in Lists
help(list_of_numbers.index)
list_of_numbers.index(number) # Return index of the number searched for
</source>One common annoyance that can occur when performing searches are '''error messages ''' when performing a search for an element that happens NOT to exist in the list. A good way to prevent those type of errors is to use a logic statement to check to see if the value for an element is in a list, then the appropriate search can be performed for that existing element value.<br><br>
:#Issue the following:<source>
list_of_numbers = [ 1, 5, 2, 6, 8, 5, 10, 2 ]
</source>
::Make notes for all of your observations in your lab log book, and proceed to Part 3.
== PART 3 - Iterating Over Lists ==
13,420
edits