Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created April 22, 2020 10:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codecademydev/f16f0b3c9eb61a1a6ccde34149ed53fd to your computer and use it in GitHub Desktop.
Save codecademydev/f16f0b3c9eb61a1a6ccde34149ed53fd to your computer and use it in GitHub Desktop.
Codecademy export
# Write your substring_between_letters function here:
def substring_between_letters(word, start, end):
begain = word.find(start)
last = word.find(end)
if begain == -1 or last == -1:
return word
else:
return word[(begain+1):last]
# Uncomment these function calls to test your function:
print(substring_between_letters("apple", "p", "e"))
# should print "pl"
print(substring_between_letters("apple", "p", "c"))
# should print "apple"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment