Module 3 - Programming Assignment - Failed test case

Hi,

I’m working on the programming assignment - Exercise 1: Encountering Data - Reading the News Article. My code follows the exact structure specified in the instructions, using open(text_file, “r”) to open the file, f.read() to read the contents, f.close() to close the file, and returning the contents.

However, the grader returns this error:

Failed test case: Your solution should not use the withstatement. Grader expected: Use only theopen()function to open the file and read it as: f = open(text_file, "r") contents = f.read() f.close() You got:with statement found in the implementation

I have verified that my submitted code does not contain a with statement and matches the expected structure. Could this be a grader issue, or is there something specific I might be overlooking? Any guidance would be appreciated.

Thank you!
Daniel

1 Like

Dear @DanDaniel,

Welcome to the Community!

Are you using with statement? If so please implement it without with
example

f = open(text_file, “r”)
contents = f.read()
f.close()

Let me know if you have any doubts.

Quoted.

Hi @DanDaniel
Have you tried clearing the cache, It frecuently gives problems remembering what you have done in the past. Also, check previous cells that may contain “with”, as the tester is very strict.

Hi @DanDaniel,

I’m going to direct message you regarding this.

1 Like

I opened the assignment from a different computer, and now I got the “All tests passed!” message in that exercise.
Thank you so much for jumping in to help!

1 Like