[Tutor] How can I make this run right?

R. Alan Monroe amonroe at columbus.rr.com
Mon Aug 15 13:04:12 CEST 2005


> The following code is supposed to take in a number, and print number!:
> n = int(raw_input("Number: "))
> x = n-1
> while 1:
>     t = n*x
>     while x > 1:
>         x -= 1
>     else:
>         break
> print t

> Why isn't it working, and how can I make it print out the correct output?

One thing you might find handy is IDLE's debugger (if you use IDLE).
Turn it on under Debug / Debugger. Make sure the "Source" checkbox is
checked. Then hit the step button to run your program in "slow motion"
so you can see everything it does one step at a time.

(You might have to temporarily click the output window to the front
when the raw_input wants you to type a number)

Alan



More information about the Tutor mailing list