Can this be done in python?
Start by print an infinite loop and changing values in between loops.
x = 5
while ( true ):
print x
x = 3 # regain control of the interpreter and set to new value
expected output:
5
5
5
......
3
3
3
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No, the code as you have written it will not work. The statement after the non-terminating loop will never get executed.
Try the following:
Alternatively, use threading, and change the value of x in a second thread: