I think you could have thought about the problem a little bit more. Also, your code looks bit sluggish. Maybe it would help if you coded some functions instead of doing everything in one go. I see a lot of code repetition in there
Anyway, here's my two cents:
The program is probably stuck in the while True:
cycle infinitely, as you only break out of the cycle when number <= 0
. I haven't read your code with too much attention, but do you intend to break out of the while True:
loop with the break
statements that are inside the while div*div<=number:
cycle? That is not possible. You would most probably need to have a variable to detect if you exit your loop prematurely and then break from the outer loop. Otherwise, maybe the else
clause of python loops may help somehow (see Control Flow in Python).