perfect number python clearer code