Hi, I don’t get why I get this error:
Unexpected ExitCode.INTERNAL_ERROR: check logs for details
It appears while I run test at the task Collatz Conjecture in the Python path. I am new to Python so I dont get what to do. If I run my code local in PyCharm there is no error an it works fine. Maybe someone can help me. Here is my code just in case:
def steps(number):
return step_two(number, 0)
def step_two(number, counter):
if (number < 0):
raise ValueError("Only positive integers are allowed")
if number == 1:
return counter
counter += 1
if number % 2 == 0:
number = int(number / 2)
print(number)
return step_two(number, counter)
if not number % 2 == 0:
number = number * 3 + 1
print(number)
return step_two(number, counter)
Hi @JohannesB05 
Welcome to the Exercism forums! Thanks for reporting this issue and for posting your code.
When I run your code against the test suite locally on my machine using pytest
, I receive the following error for the test_zero_is_an_error
test case:
E RecursionError: maximum recursion depth exceeded
!!! Recursion detected (same locals & position)
This is happening because your code is not trapping the scenario where the input is equal to zero - it is only checking for when the input is less than zero.
Because your code is not exiting/raising an error when number == 0
, it keeps on recursing until it hits Python’s internal recursion limit (1000 calls). Then, everything stops because the Python interpreter exits.
That recursion limit is there to prevent the Python language and runtime or your computer from badly crashing.
Our online test runner didn’t surface the error to you because the print()
statements and error stack exceeded the allowable amount of characters (500) we can output, so we were unable to compile and return a JSON report for the UI.
If you remove the print()
statements from your code, you will see the following in the UI for test output:
For more information on recursion in Python, see the following links:
-
Pydon’t Recursion (this one is really good, and has great references at the end).
-
Python Docs: Recursion Error
-
Sys (recursion limit)
-
Sys (set or change recursion limit) – WARNING - changing this is almost never the answer when you have a violation of the recursion limit. Instead, you should be looking at how your recursion is structured, whether or not you can memoize, or if you need to resort to other strategies or methods.
So one small change in your code (and the removal of the print()
statements) should get things working in the online editor.
But you can also check your progress locally in PyCharm by setting up Pytest on your computer and running the tests there. For more information on that, see Testing on the Python track, and let us know if you have any additional questions or issues. 
4 Likes