Changes

Jump to: navigation, search

OPS435 Python Lab 3

38 bytes added, 10:51, 3 June 2017
PART 3 - Iterating Over Lists
:::*The list '''my_list''' should have the values: '''1, 2, 3, 4, 5'''
:::*The script should have a function called '''add_item_to_list(my_list)''' <ul><li>This function takes a single argument which is a list name itself. This function will look at the value of the last item in the list, it will then append a new value that is one unit bigger (i.e. '''+1''') than the previous existing list item (element). This function modifies the list without returning any value.</li></ul>
:::*The script should have a function called '''remove_items_from_list(my_list, items_to_remove)'''
:::*The function '''add_item_to_list(my_list''') takes a single argument which is a list. This function will look at the value of the last item in the list, it will then append a new value that is '''+1''' bigger then the previous number. This function modifies the list without returning any valueT
:::*The function '''remove_items_from_list(my_list, list_of_numbers_to_remove)''' takes two arguments, a list, and a list of numbers to remove from the list. This function will then check if those items are in the list, if they are it will remove them. This function modifies the list without returning any value.
13,420
edits

Navigation menu