Getting a loop to activate a loop above it
Terry Hancock
hancock at anansispaceworks.com
Wed Mar 22 18:12:54 EST 2006
On 22 Mar 2006 13:07:33 -0800
"Byte" <eoinrogers at gmail.com> wrote:
> The following code will not work for me:
>
> x = 1
>
> while x == 1:
> print 'hello'
> x = input('What is x now?: ')
>
> while x == 2:
> print 'hello again'
> x == input('What is x now?: ')
>
> The second loop dose not seem to be able to activate the
> loop above it....
> Proof from my command line:
>
> $ python program-that-dose-not-work.py
> hello
> What is x now?: 2
> hello again
> What is x now?: 1
> hello again
> What is x now?:
>
> So, now I ask you: how do I make it work?
Curious.
What did you expect it to do, and what sort of experience
made you think it ought to do that?
It seems like anyone who had ever seen an Algol-derived
programming language would expect exactly what happens, and
I think so would a "naive" user.
My impression is that you imagine you are writing "rules"
instead of a "program". That's such an odd expectation, I
am curious what led you to think that way. Do you
have prior experience with inference engines or something?
Jordan Greenberg has already answered your actual question,
so I won't repeat. :-)
Cheers,
Terry
--
Terry Hancock (hancock at AnansiSpaceworks.com)
Anansi Spaceworks http://www.AnansiSpaceworks.com
More information about the Python-list
mailing list