Change in range() function according to python 3 and corrected some errors