Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. This Python function takes in a list of words (all_words) and a prefix and returns
  2. a new list of words (words_with_prefix) containing all the words in that list starting
  3. with the specified prefix.
  4. """
  5. def get_words_with_prefix(all_words, prefix):
  6. words_with_prefix = None
  7. for word in all_words:
  8. if word[0:len(prefix) - 1] is prefix:
  9. words_with_prefix += word
  10. return words_with_prefix
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement