Very basic question. How do I start again?
Ben Finney
ben+python at benfinney.id.au
Thu Aug 21 21:55:58 EDT 2014
Seymore4Head <Seymore4Head at 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.
--
\ “Religious faith is the one species of human ignorance that |
`\ will not admit of even the *possibility* of correction.” —Sam |
_o__) Harris, _The End of Faith_, 2004 |
Ben Finney
More information about the Python-list
mailing list