I have translated code from Python 2.7 to Python 3.4