Changes

Jump to: navigation, search

OPS435 Python Lab 3

108 bytes removed, 10:08, 29 January 2018
PART 3 - Iterating Over Lists
== 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 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'''
::Let's take a moment to understand how the '''for''' loop works. This The following '''for''' loop will store the value of each list element from list_of_numbers within a variable named '''item''' and run code indented below the loop for each item.<br><br>
:#Issue the following in the ipython shell:<source lang="python">
list_of_numbers = [ 1, 5, 2, 6, 8, 5, 10, 2 ]

Navigation menu