Persistent failure of 'break' statement ( novice )

John Machin sjmachin at
Sat Jun 13 22:03:38 EDT 2009

On Jun 14, 10:20 am, pdlem... at wrote:

> Now no error message, but it will go on forever despite repeatedly
> entering 0.  Have to get out with ctrl-c .    

>            Frusting: I'm missing something fundamental. Dave WB3DWE

After you hit the zero key, do you hit the Enter key?

If the answer is yes, then our crystal balls have proved useless.
You'll have to supply some meaningful detail. If you are pasting your
script into a Python interactive prompt, stop doing that, save your
script as a file, and run it from the command line.

Here's a script for you to use. It has some diagnostic print() calls
in it so that we can see what is going wrong.

8<----- cut here
import sys
assert sys.version.startswith('3.')
while True :
    text = input('Enter a number -> ')
    print('You entered', ascii(text))
    if text != "0":
        print('That is NOT the digit zero!')
    num = int(text)
    print('Value:', num)
    if num == 0:
8<----- cut here

And when you run it, copy the outout and paste it into your return
message/posting, like I've done below:

[I called my copy]

3.0.1 (r301:69561, Feb 13 2009, 20:04:18) [MSC v.1500 32 bit (Intel)]
Enter a number -> 9
You entered '9'
That is NOT the digit zero!
Value: 9
Enter a number -> 0
You entered '0'
Value: 0


Hoping this helps,

More information about the Python-list mailing list