Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """ A program that returns a list of times the character a appears in a list of words """
- # For flexibility, user is expected to type words where comma is used as
- # as a delimiter between every two word
- type_words = input("Enter your list of word and use a comma and whitespace \
- as a separator between two word: ")
- word = type_words.split(", ") # The splits the words to a list
- # The count_of_a function declaration
- def count_of_a(words):
- print(list(map(lambda word: word.count("a"), words)))
- # The function invocation
- count_of_a(word)
- # Enter your list of word and use a comma and whitespace as a separator between
- # two word: alligator, aardvark, albatross
- # [2, 3, 2]
- # Enter your list of word and use a comma and whitespace as a separator between
- # two word: plywood
- # [0]
- # Enter your list of word and use a comma and whitespace as a separator between
- # two word:
- # [0]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement