()
| 27 | |
| 28 | # step2: |
| 29 | def 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 | |
| 44 | if __name__ == "__main__": |