Refactoring; replaced for-loop with list comprehension and added doctests
to code; now using Python3 syntax