Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update 031_list_modification.py #17

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions 031_list_modification.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def append_item_to_list(the_list, item):
print("Function: remove_item_from_list")

def remove_item_from_list(the_list, item):
# ...
the_list.remove(item)
return the_list

# If you have trouble here, make sure you're returning the
Expand All @@ -87,7 +87,7 @@ def remove_item_from_list(the_list, item):
print("Function: count_items_in_list")

def count_items_in_list(the_list, item):
return # ...
return the_list.count(item)

# Whereas here you'll need to return the result of the
# function you call, not the list.
Expand All @@ -102,7 +102,7 @@ def count_items_in_list(the_list, item):
print("Function: get_index_of_item")

def get_index_of_item(the_list, item):
return # ...
return the_list.index(list)

check_that_these_are_equal(
get_index_of_item(['a', 'b', 'c'], 'b'), 1)
Expand All @@ -115,8 +115,7 @@ def get_index_of_item(the_list, item):
print("Function: reverse_list")

def reverse_list(the_list):
# ...
return the_list
return list(reversed(the_list))

check_that_these_are_equal(
reverse_list(['a', 'b', 'c']), ['c', 'b', 'a'])
Expand All @@ -130,7 +129,7 @@ def reverse_list(the_list):

# Note — it's the same as for strings!
def list_length(the_list):
return # ...
return len(the_list)

check_that_these_are_equal(
list_length(['a', 'b', 'c']), 3)
Expand Down