Created
April 11, 2023 19:07
-
-
Save pylearner1007/48f225d4efe51d46da539c9684f9fd30 to your computer and use it in GitHub Desktop.
def get_words(sentence, n):
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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