Changes

Jump to: navigation, search

OPS435 Python Lab 4

255 bytes added, 14:12, 15 June 2017
PART 3 - Dictionaries
set_of_values = set(dict_york.values())
set_of_keys | set_of_values
</source>::#The lists Lists can be iterated over in a used with '''for looploops'''. To Demonstrate, issue the following for loops.<source>
list_of_keys = list(dict_york.keys())
for key in list_of_keys:
for value in dict_york.values()
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>::#To demonstrate, issue the following:<source>
list_of_keys = list(dict_york.keys())
list_of_values = list(dict_york.values())
list_of_values[0]
</source>
::#Using this By using this generated list of indexes , we are able to pair the keys and values of two separate lists.<br><br>::#For example, issue the following:<source>
list_of_keys = list(dict_york.keys())
list_of_values = list(dict_york.values())
13,420
edits

Navigation menu