MCPcopy Index your code
hub / github.com/geekcomputers/Python / check_first_letter

Function check_first_letter

1 File handle/File handle text/question3.py:29–41  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

27
28# step2:
29def check_first_letter():
30 with open(file_name) as F:
31 lines = F.read().split()
32
33 # store all starting letters from each line in one string after converting to lower case
34 first_letters = "".join([line[0].lower() for line in lines])
35
36 count_i = first_letters.count("i")
37 count_m = first_letters.count("m")
38
39 print(
40 f"The total number of sentences starting with I or M are {count_i + count_m}"
41 )
42
43
44if __name__ == "__main__":

Callers 1

question3.pyFile · 0.70

Calls 1

countMethod · 0.80

Tested by

no test coverage detected