/cxldata/datasets/project/mbox-short.txt
Do we have to create this path/file? Do not see it in “Files”?
/cxldata/datasets/project/mbox-short.txt
Do we have to create this path/file? Do not see it in “Files”?
Path is clearly mentioned in the project …it’s in /cxldata not in your home folder
Thank you for that Mr.Abhinav.
Could you please look into my second query.
It is showing the right count but when I submit it shows :" Wrong count"
Hi, Pavan.
Your solution is elegant.
When you will open a file and declare a variable count after it, the file will close immediately.
So, Remove the count and put on the top like below.
def count_number_of_lines():
count=0
fhand=open(’/cxldata/datasets/project/mbox-short.txt’):
for line in fhand:
…
Now you can proceed with your logic.
It should work!
All the best!
def count_number_of_lines():
count = 0
with open(’/cxldata/datasets/project/mbox-short.txt’) as f:
for line in f:
line = line.rstrip() # Remove new line characters from right
if line.startswith('Subject:'):
count = count + 1
return count
count_number_of_lines()
got correct answer but after submitting it is saying wrong answer?
Can you take inspiration from Hint?