Skip to content

Commit 510fa80

Browse files
committed
list modification exercises complete
1 parent cdbf56c commit 510fa80

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

031_list_modification.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def append_item_to_list(the_list, item):
7171
print("Function: remove_item_from_list")
7272

7373
def remove_item_from_list(the_list, item):
74-
# ...
74+
the_list.remove(item)
7575
return the_list
7676

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

8989
def count_items_in_list(the_list, item):
90-
return # ...
90+
return the_list.count(item)
9191

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

104104
def get_index_of_item(the_list, item):
105-
return # ...
105+
return the_list.index(item)
106106

107107
check_that_these_are_equal(
108108
get_index_of_item(['a', 'b', 'c'], 'b'), 1)
@@ -115,7 +115,7 @@ def get_index_of_item(the_list, item):
115115
print("Function: reverse_list")
116116

117117
def reverse_list(the_list):
118-
# ...
118+
the_list.reverse()
119119
return the_list
120120

121121
check_that_these_are_equal(
@@ -130,7 +130,7 @@ def reverse_list(the_list):
130130

131131
# Note — it's the same as for strings!
132132
def list_length(the_list):
133-
return # ...
133+
return len(the_list)
134134

135135
check_that_these_are_equal(
136136
list_length(['a', 'b', 'c']), 3)

0 commit comments

Comments
 (0)