Skip to content

Commit c40e2a2

Browse files
committed
string slicing task complete
1 parent b08ac40 commit c40e2a2

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

023_string_indexing.py

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

5353
def get_first_letter(the_str):
5454
# Return the first letter of the string
55-
pass
55+
return the_str[0]
5656

5757
check_that_these_are_equal(
5858
get_first_letter("The king granted them"),
@@ -71,7 +71,7 @@ def get_first_letter(the_str):
7171

7272
def get_last_letter(the_str):
7373
# Return the last letter of the string
74-
pass
74+
return the_str[-1]
7575

7676
check_that_these_are_equal(
7777
get_last_letter("The king granted them"),
@@ -90,7 +90,7 @@ def get_last_letter(the_str):
9090

9191
def get_nth_letter(the_str, n):
9292
# Return the letter of the string at the specified index
93-
pass
93+
return the_str[n]
9494

9595
check_that_these_are_equal(
9696
get_nth_letter("The king granted them", 4),
@@ -110,7 +110,7 @@ def get_nth_letter(the_str, n):
110110
def get_letters_between_four_and_eight(the_str):
111111
# Return the section of the string between indexes four
112112
# and eight
113-
pass
113+
return the_str[4:8]
114114

115115
check_that_these_are_equal(
116116
get_letters_between_four_and_eight("The king granted them"),

0 commit comments

Comments
 (0)