#๐Ÿ”’ Python Homework: Testpy call function directly write without overlap?

20 messages ยท Page 1 of 1 (latest)

stark cipher
#

Annoyingly, my professor's test is calling my function directly. But, how am I supposed to open (and close) this file without overwriting?

I could append, but the problem is this runs multiple tests, all checking for different values.

I pass the first 3 tests, because those go through my main() function. However the last bunch of tests just call my function directly.

cobalt galleonBOT
#

@stark cipher

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

ornate idol
#

Screenshots are unreadable when scaled like this

stark cipher
#

???

#

Open it in browser

#

It's 2560x1440 image

ornate idol
#

...

stark cipher
#

I took a photo of the whole IDE because I am trying to show both sides of the code

#

Discord makes images smaller in app

#

Essentially what is happening:

Since the text calls the function directly, I am writing every time and overwriting the file.

However how else am I supposed to open (then close) the file? I'm doing that inside the function, if they run it every time then it's going to keep closing/opening it

#

I changed the w to an a to append as it seems the professor resets our files inside their own tests

tranquil crater
#

can u send the code instead ?

stark cipher
#

I fixed it. The test was just designed in a way that I don't really think is a fair design

#

!close

cobalt galleonBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.