Updated the code for Python3