Advertisement
ganiyuisholaafeez

Existence and Length of a word

Feb 22nd, 2020
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.56 KB | None | 0 0
  1. """ The function to test if a word exists in a list
  2. and it has more than 4 characters"""
  3.  
  4. #The function is named long_word_in_collection and it has accepts two arguments
  5. def long_word_in_collection(list_of_words, word):
  6.     if word in list_of_words and len(word) > 4: # Word Existence and Length
  7.         return True
  8.     else:
  9.         return False
  10.  
  11. print(long_word_in_collection(["cat", "dog", "rhino"], "rhino")) # True
  12. print(long_word_in_collection(["cat", "dog", "rhino"], "cat")) # False
  13. print(long_word_in_collection(["cat", "dog", "rhino"], "monkey")) # False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement