Changes

Jump to: navigation, search

OPS435 Python Lab 3

19 bytes removed, 19:32, 14 August 2017
PART 3 - Iterating Over 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 an '''if''' 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 lang="python">
list_of_numbers = [ 1, 5, 2, 6, 8, 5, 10, 2 ]
== PART 3 - Iterating Over Lists ==
:This last section demonstrates an extremely useful for lists: the ability to quickly '''loop through every value in the list'''. '''For loops''' have a set number of times they loop. The '''for''' loop (a "determinant" loop) will execute all indented code for each item (element) in the list. Using loops with list allow for efficient processing of stored data.
:'''Perform the Following Steps'''

Navigation menu