OsahonE

Wk5_1

Apr 1st, 2020
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.34 KB | None | 0 0
  1. def right_words(list, num):
  2.     result = []
  3.    
  4.     #iterating through the list and stating the condition that length of values in list must be equal to num for it to append to the result list, we have:
  5.        
  6.     for values in list:
  7.         if len(values) == num:
  8.             result.append(values)
  9.     return result
  10. print(right_words(["cat", "heart", "ace", "bean"], 3))
Advertisement
Add Comment
Please, Sign In to add comment