Simple python script is not printing output

See this lovely debug blog for help. Most of all, learn to use a print to trace the problem, or desk-check the program (simulate with paper & pencil).

Look at your very first iteration:

x = 1500000
y = 0

while (x>0):
    x=(x * 1.1) - 20000

Evaluate this line:

x = (1500000 * 1.1) - 20000
x = 1650000 - 20000
x = 1630000

x is now larger than before. It will continue to escalate without bound. You never reach your while‘s exit condition, so you never reach the print statement.

Leave a Comment