0% found this document useful (0 votes)
2 views1 page

Code

The document contains a Python script that reads lines from a file named 'abc.txt'. It counts the number of lines that start with 'a' or 'A', the number of lines that end with 'a', and the number of lines that both start and end with 'a'. Finally, it prints these counts to the console.

Uploaded by

prabhakaran4558
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views1 page

Code

The document contains a Python script that reads lines from a file named 'abc.txt'. It counts the number of lines that start with 'a' or 'A', the number of lines that end with 'a', and the number of lines that both start and end with 'a'. Finally, it prints these counts to the console.

Uploaded by

prabhakaran4558
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

f = open("abc.

txt","r")
r = [Link]()
c1 = c2 = c3 = 0
for i in r:
if ([Link]('a') or [Link]('A')) and ([Link]('a') or
[Link]('a')):
c1 = c1+1
if [Link]('a') or [Link]('A'):
c2 = c2+1
if [Link]('a') or [Link]('a'):
c3 = c3+1
print("The number of lines startswith and also endswith a:",c1)
print("The number of lines startswith a:",c2)
print("The number of lines endswith a:",c3)

You might also like