Skip to content

Instantly share code, notes, and snippets.

@pylearner1007
Created April 11, 2023 19:07
Show Gist options
  • Select an option

  • Save pylearner1007/48f225d4efe51d46da539c9684f9fd30 to your computer and use it in GitHub Desktop.

Select an option

Save pylearner1007/48f225d4efe51d46da539c9684f9fd30 to your computer and use it in GitHub Desktop.
def get_words(sentence, n):
def get_word(sentence, n):
# Only proceed if n is positive
if n > 0:
words = ___
# Only proceed if n is not more than the number of words
if n <= len(words):
return(___)
return("")
print(get_word("This is a lesson about lists", 4)) # Should print: lesson
print(get_word("This is a lesson about lists", -4)) # Nothing
print(get_word("Now we are cooking!", 1)) # Should print: Now
print(get_word("Now we are cooking!", 5)) # Nothing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment