Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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