Smart Number Hackerrank Solution Python