Last active
May 8, 2021 10:13
-
-
Save computer-tutor/2a5562d4e07027581b78b31d59c49df4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def func_start_A(l): # function to count lines starting with ‘A’ | |
c = 0 # c is the count of such lines | |
for line in l: | |
if line.startswith('A'): | |
c += 1 | |
return c | |
f1 = open('LINES.txt', 'r') | |
l = f1.readlines() # creates a list of all the lines in the file | |
print('Number of lines starting with A in the file LINES.txt is', func_start_A(l)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment