Ad
  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    The test "arr()" fails due to not passing a required parameter into the arr(n) function. Please remove this test or indicate in the test description that the parameter should be optional (this is an 8kyu level test and is going to cause beginners issues).

  • Custom User Avatar

    @voodoonissen What error message does your compiler return when you use an optional argument? I may be mistaken, but I'm 99% sure a TypeError is only thrown when a function or operator is used in a way it isn't designed for. The above test given by @valkyrie tests arr(), with no arguments. Since arr() is not designed for this, a TypeError is thrown. But with an optional argument, it is defined for this type of call. So it does not throw a TypeError. Where are you saying I'm making a mistake?

    Another thing is, calling arr() is equivalent to calling arr(None) (correct me if I'm wrong), which is why your solution works. However, if you wanted to set n to some value other than zero as a default, the code would be a lot more complicated. So, in my opinion, using a default or optional argument is best practice in general.

  • Custom User Avatar
  • Custom User Avatar

    Your function name is wrong.

    (Also not a issue with the problem)

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    Description lacks the requirement of function being callable without params though. This needs to be added, just sample test is not enough.

  • Custom User Avatar

    Tests are fine, problem is with your code.

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution