Refactoring a bit Python Problem 4. Not finished.