Changes

Jump to: navigation, search

OPS435 Python Lab 4

162 bytes added, 17:32, 15 June 2017
PART 3 - Dictionaries
print(value)
</source>Additional Information regarding Dictionaries:<ul><li>The values and keys can be looped over using the index as well
::#The '''range()''' function provides a list of numbers in a range.</li><li>The '''len()''' function provides a the number of items in a list.</li><li>Used together '''len() and range()''' can be used to create a list of usable indexes for a specific list</li></ul><br><br>Let's construct a table using lists created to store our dictionary data. First, we need to pair the keys and values of two separate lists.<br><br>::#To demonstrate, issue Issue the following:<source>
list_of_keys = list(dict_york.keys())
list_of_values = list(dict_york.values())
list_of_keys[0]
list_of_values[0]
</source>By using this generated list of indexesNow, we are able let's use these ''newly-created lists'', ''len()'' &amp; '''range()''' functions with a ''for loop'' to pair the keys and values of two separate lists.construct our table:<br><br>
::#For example, issue the following:<source>
list_of_keys = list(dict_york.keys())
13,420
edits

Navigation menu