Getting a loop to activate a loop above it

Terry Hancock hancock at
Thu Mar 23 00:12:54 CET 2006

On 22 Mar 2006 13:07:33 -0800
"Byte" <eoinrogers at> 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
> 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?


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. :-)


Terry Hancock (hancock at
Anansi Spaceworks

More information about the Python-list mailing list