Getting a loop to activate a loop above it

Byte eoinrogers at gmail.com
Wed Mar 22 22:07:33 CET 2006


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?

Thanks in advance,
 -- /usr/bin/byte




More information about the Python-list mailing list