Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # This program declares a function that accepts two parameters, a_list and number and returns a new list with words that have a length equal to the number
- #function
- def right_words(a_list, number):
- items = [ ]
- for item in a_list:
- if len(item)==number:
- items.append(item)
- print(items)
- right_words(["cat", "dog", "bean", "ace"], 3) # Example (the first argument must be a list consisting of words, the 2nd argument must be a number)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement