Ad
  • Default User Avatar

    What happens if you drop the stack from your solution? Does it work the same without it?

    Looking at your code, I'd say ")(" is probably the simplest case that will make it fail.
    Print out important variables to see what your code does.

  • Custom User Avatar

    Whatever the two tests (failing) are expecting is what my code is giving as outputs.

    You got this part wrong. Sample tests are OK, and your solution has an error and returns wrong results.

    Run your solution locally, in your IDE, for example with parameter "" (i.e. empty string). Sample tests expect it to return True. Check locally what it returns. It will probably make easier for you to find your mistake.

  • Custom User Avatar

    Not an issue. Your solution doesn't even pass the "" sample test. And use spoiler tags.

  • Default User Avatar

    Mutating the input is changing the parameter in a function. For instance:

    a = [1, 2, 3, 4]
    def sumlist(x):
      total = 0
      while len(x) > 0:
        total += x[0]
        x.remove(x[0])
      return total
    res = sumlist(a)
    print(a)# will print []
    #list a is modified, which is bad most of the time.
    
  • Custom User Avatar

    Don't mutate the inputs. Never. Unless you're told you can explicitely.
    But so, it was an issue.

    edit: corrected

  • Custom User Avatar

    Not an issue. Print the inputs.