a guest Feb 21st, 2020 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- """# This super_sum function accepts a list of one or more strings and sums up the
- index position of the first occurence of the letter "s"
- def super_sum(ssum):
- total = 0
- s_counts = 
- for anystring in ssum: #iterates over every character in the list passed to it
- if "s" in anystring: #checks for the character "s" in the elements of the strings passed to it
- index_positions = (anystring.index("s"))
- """#creating a variable to store the index position
- of the first occurence of the character "s"
- #print(index_positions) #To check if i was getting the right index positions of the found "s" character in the string
- s_counts.append(index_positions) #To add all the index positions to a list, to be able to iterate them and add them.
- #print (s_count) #To check if the expected list was created
- for counts in s_counts: #to iterate the generated index positions of the character "s", so as to add up easily
- total += counts #the process of adding up the list of the index positions of the character "s"
- return total
- print(super_sum(["Jesus", "sweet", "anybody", "grass"]))
- print(super_sum(["asus", "rest", "pies"]))
RAW Paste Data