Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #76766
| From | Seymore4Head <Seymore4Head@Hotmail.invalid> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: Very basic question. How do I start again? |
| Date | 2014-08-21 22:13 -0400 |
| Message-ID | <td9dv91bdncnpa46psag7o7lf06iftbrnq@4ax.com> (permalink) |
| References | <1e5dv9l3aik5bb1jn4vil731rdl7q6sl3l@4ax.com> <mailman.13268.1408672574.18130.python-list@python.org> |
| Organization | Unlimited download news at news.astraweb.com |
On Fri, 22 Aug 2014 11:55:58 +1000, Ben Finney
<ben+python@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)
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Very basic question. How do I start again? Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-08-21 21:37 -0400
Re: Very basic question. How do I start again? Ben Finney <ben+python@benfinney.id.au> - 2014-08-22 11:55 +1000
Re: Very basic question. How do I start again? Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-08-21 22:13 -0400
Re: Very basic question. How do I start again? Chris Angelico <rosuav@gmail.com> - 2014-08-22 12:24 +1000
Re: Very basic question. How do I start again? Chris Angelico <rosuav@gmail.com> - 2014-08-22 11:58 +1000
Re: Very basic question. How do I start again? Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-08-21 22:18 -0400
Re: Very basic question. How do I start again? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-08-21 23:17 -0400
Re: Very basic question. How do I start again? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-08-22 12:58 +1000
Re: Very basic question. How do I start again? Denis McMahon <denismfmcmahon@gmail.com> - 2014-08-22 04:26 +0000
Re: Very basic question. How do I start again? Tim Roberts <timr@probo.com> - 2014-08-21 22:56 -0700
Re: Very basic question. How do I start again? Igor Korot <ikorot01@gmail.com> - 2014-08-21 23:21 -0700
csiph-web