def countlines():
file=open("D:\story.txt.txt")
lines=file.readlines()
count=0
for word in lines:
if word[0]=="A" or word[0]=="a":
count=count+1
print("total lines",count)
file.close
#main program
countlines()
Input
file name: story.txt
abcdefoiioioio
h8uhyhy8
Ai9hpu
u8y8887
a9j-j8okjioij
output
Python 3.7.4 (tags/v3.7.4:e09359112e, Jul 8 2019, 19:29:22) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>>
============== RESTART: C:/Users/Student/Desktop/12cs/fi-21.py ==============
total lines 3
>>>
file=open("D:\story.txt.txt")
lines=file.readlines()
count=0
for word in lines:
if word[0]=="A" or word[0]=="a":
count=count+1
print("total lines",count)
file.close
#main program
countlines()
Input
file name: story.txt
abcdefoiioioio
h8uhyhy8
Ai9hpu
u8y8887
a9j-j8okjioij
output
Python 3.7.4 (tags/v3.7.4:e09359112e, Jul 8 2019, 19:29:22) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>>
============== RESTART: C:/Users/Student/Desktop/12cs/fi-21.py ==============
total lines 3
>>>
My output is not coming and no error now what should i do
ReplyDelete