Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """ This function searches the returns the index of the first occurence of
- letter s in a list of strings and sums all the indexes and the returns the totals """
- def run_a_search(Names):
- total = 0 # Base Total
- for Name in Names:
- if "s" in Name: # Searching for s
- total += Name.index("s") # Summing up the indexes
- return total
- print(run_a_search([])) # 0
- print(run_a_search(["mustache"])) # 2
- print(run_a_search(["mustache", "greatest"])) # 8
- print(run_a_search(["mustache", "pessimist"])) # 4
- print(run_a_search(["mustache", "greatest", "almost"])) # 12
- print(run_a_search(["Scholars", "Networks", "Is", "Best"])) # 17
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement