Python project: churn email

Hi

I have attempted all the questions and exercises in this project and got the correct answer for all the questions but after submitting the code…it is saying wrong answer…why is that. I have matched my code with the perfect ones but still none of the answer is accepted by the system…please help quickly

Q-1: Count the Number of Lines

code is below:
def number_of_lines():
fhand = open(’/cxldata/datasets/project/mbox-short.txt’)
inp = fhand.read()
fhand.close()
count=len(inp.splitlines())
return count
number_of_lines()

got 1910 as answer but system not accepring

Q-2: Count the Number of Subject Lines
code is:

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    

answer is 27. but not accepted by system

q-3: Find Average Spam Confidence

code:

def average_spam_confidence():
with open(’/cxldata/datasets/project/mbox-short.txt’) as f:
count = 0
spam_confidence_sum = 0
for line in f:
line = line.rstrip() # Remove new line characters from right
if line.startswith(‘X-DSPAM-Confidence:’):
var, value = line.split(’:’)
spam_confidence_sum = spam_confidence_sum + float(value)
count = count + 1
return spam_confidence_sum/count
average_spam_confidence()

answer: 0.7507185185185187

but still error on submission

and………same for other exercises as well

@satyajit_das Same goes for me. And this is not only for the Churn Email project but also for the Bike Assessment project. The questions are correct, and so are the results as given in the tutorial. I am getting the results as expected, yet it is giving me errors. Just to check if I am doing anything wrong, I have copy pasted the codes given in the hints, they still gives me errors when I am trying to mark them as complete. I have mailed the notebook for your reference. Please help, I am unable to mark the projects as complete even though I have completed them.

Hi @Amit_Chaturvedi @Rajtilak

The system not only checks for the answer but logical errors also.

All the questions are correct. In case you are stuck, you can use Hint and “See Answer”. This way you will be able to figure out logical errors in your code.

Unfortunately, this is project and we want you to fix the code.

Hi @abhinav, thanks for the quick reply. I don’t think I was able to express myself properly. I am not saying the questions are incorrect. The questions, and the results are correct. Yet, I am still getting those errors. Also, even when I blindly copy paste the codes given in the hints, it still shows there’s an error. Let me assure you that there are no logical errors. I have double checked my solutions, I have double checked the hints too. Let me give you an example, one of the requirement is to import numpy, which is a code as simple as import numpy as np, the hints shows the same too, yet this is being shown as an error. Let me know if you need any further details pertaining to this, I would be more than happy to help.

@Rajtilak and @Amit_Chaturvedi

I have sent you an email. Lets see this over the zoom call.

I just talked to the @Amit_Chaturvedi over the call and the system is expecting his answers in the Python Email Churn project.

@Rajtilak, I think you have posted this question on a different topic. We are fixing the test cases in the remaining topics.

If there is any problem you are facing in Chhurn email projet and then please let me know. For help in any other topic, please open a new discussion comment.

1 Like

Hi @abhinav, this was regarding the Email Churn project, however, after receiving your email when I tried to resubmit the results the system accepted them! I didn’t change even a line of code before submitting the same today. Not sure what I was doing wrong. But thank you for all your help, even on Sundays.

This is strange. What kind of error were you getting? Could you please share the screenshot if possible?

1 Like

@Rajtilak
I have reviewed your project and found that your code is correct in all the form.
But you have done that in a separate file that you have created as “Python Project-Churn Emails”. But you need to write all the codes in the given jupyter notebook provided called “Python.ipynb” which is under “cloudxlab_jupyter_notebooks” you are getting error because our system is evaluating the variables/outputs from this notebook(basically checking the path and variables), but you are doing in some other notebook present in other path, that is why none of your answer is accepting in spite of correct answers.
So, I request you to please write all your programs in Python.ipynb file and you will be able to complete your projects.
I recommend you to follow the same for all projects.

All the best! Happy Learning.

1 Like

Hi @satyajit_das and @abhinav, this issue has been resolved. Although I am still a bit confused since I didn’t change any code since last time, I didn’t do it in the notebook under “cloudxlab_jupyter_notebooks”. I just read @abhinav’s reply that @Amit_Chaturvedi’s solution was working and thought I should give it a go, and to my surprise all the codes passed without any hiccup. @abhinav the errors were pretty simple, a line missing, a variable not defined etal. Even though those were not the case. I am facing similar challenges with some of my other projects, but I would open a separate thread for them. Once again, thank you all for being so helpful.