0

Here is my code:

def fibs(n):
    count = 0
    val1 = 1
    val2 = 1
    while count != n:
       yield val1
       count += 1
       yield val2
       count += 1
       val1 += val2
       val2 += val1
    
def main():
    for curr in fibs(8):
       print(curr)

When I upload this to gradescope it is telling me that the autograder failed to execute correctly. Can anyone guess why this is happening ?

AlexisG
  • 2,476
  • 3
  • 11
  • 25
MSS
  • 1
  • 2
  • Try running your code on a different online sandbox like https://ideone.com/6S6WVN, and you'll see it has no output at all. – Charles Duffy Sep 21 '21 at 14:12
  • Hint: What actually _calls or starts your `main()` function_? – Charles Duffy Sep 21 '21 at 14:14
  • ...compare the above to, say, https://ideone.com/YRfkin – Charles Duffy Sep 21 '21 at 14:17
  • They say that nothing should be printed in the code in order to be graded correctly, therefore I did not put any calls to main(). – MSS Sep 21 '21 at 14:18
  • What _exactly_ is the specification? That may have meant no logging info on stdout _except the output itself_. – Charles Duffy Sep 21 '21 at 14:31
  • Here is the exact error I get: ""The autograder failed to execute correctly. Please ensure that your submission is valid."" – MSS Sep 21 '21 at 15:57
  • I didn't ask for the error. I asked for the specification. Things like "nothing should be printed" is part of the specification your code is expected to comply with. – Charles Duffy Sep 21 '21 at 20:10
  • ""Implement a function def fibs(n). This function is given a positive integer n, and returns a generator, that when iterated over, it will have the first n elements in the Fibonacci sequence."' a. Name all classes, functions and methods exactly as they are in the assignment specifications. b. Make sure there are no print statements in your code. If you have tester code, please put it in a “main” function and do not call it. – MSS Sep 22 '21 at 00:47
  • "in the assignment specification" -- that's what I asked for. But yes, that _is_ explicit that it doesn't want main to be called. I still don't think this is an on-topic question -- something needs to be about a narrow, specific problem to be on-topic here, and if you don't _know_ what the specific problem is then we're stuck in the dark guessing as much as you -- but the current close reason is indeed clearly incorrect. – Charles Duffy Sep 22 '21 at 01:45
  • BTW, that kind of clarifying detail should be in the question itself, not just comments. – Charles Duffy Sep 22 '21 at 01:47

0 Answers0