Skip to content

Commit cdbf56c

Browse files
committed
list indexing exercises complete
1 parent d4609ef commit cdbf56c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

030_list_indexing.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
def get_first_item(the_list):
2525
# Return the first item of the list
26-
pass
26+
return the_list[0]
2727

2828
check_that_these_are_equal(
2929
get_first_item(["a", "b", "c", "d", "e"]),
@@ -42,7 +42,7 @@ def get_first_item(the_list):
4242

4343
def get_last_item(the_list):
4444
# Return the last item of the list
45-
pass
45+
return the_list[-1]
4646

4747
check_that_these_are_equal(
4848
get_last_item(["a", "b", "c", "d", "e"]),
@@ -61,7 +61,7 @@ def get_last_item(the_list):
6161

6262
def get_nth_item(the_list, n):
6363
# Return the item of the list at the specified index
64-
pass
64+
return the_list[n]
6565

6666
check_that_these_are_equal(
6767
get_nth_item(["a", "b", "c", "d", "e"], 3),
@@ -81,7 +81,7 @@ def get_nth_item(the_list, n):
8181
def get_items_between_one_and_three(the_list):
8282
# Return the section of the list between indexes one
8383
# and three
84-
pass
84+
return the_list[1:3]
8585

8686
check_that_these_are_equal(
8787
get_items_between_one_and_three(["a", "b", "c", "d", "e"]),

0 commit comments

Comments
 (0)