On Fri, 22 Aug 2014 11:55:58 +1000, Ben Finney <ben+pyt...@benfinney.id.au> wrote:
>Seymore4Head <Seymore4Head@Hotmail.invalid> writes: > >> The program works as expected until the computer gets a correct guess. >> I don't know what I should be doing to restart the program when >> pick=guess. > >There isn't a restart the program code we can give. But I think you >need only something rather simpler: > >> while count < 100: >> guess = random.randrange(low,high) >> print (pick, guess) >> if guess == pick: >> print ("correct") >> >> #"What I need is something here that says start over" > >You can end the current loop with the break statement. See the docs ><URL:https://docs.python.org/3/reference/simple_stmts.html#the-break-statement> >to see exactly what its semantics are, and try using that in your code. > >Feel free to ask further questions when you've tried that, if it's still >not clear. Thanks for the tip, but my trial and error failed. I tried putting break_stmt ::= "break" at the point where I want to start over....:) ,but since there is no "start ove"r command, I was happy to end the program. I get "invalid syntax so I tried break_stmt Traceback (most recent call last): File "C:/Documents and Settings/Administrator/Desktop/Python 3.4/Functions/random.py", line 11, in <module> guess = random.randrange(low,high) File "C:\Python34\lib\random.py", line 196, in randrange raise ValueError("empty range for randrange() (%d,%d, %d)" % (istart, istop, width)) ValueError: empty range for randrange() (37,37, 0) -- https://mail.python.org/mailman/listinfo/python-list