Here is my stupid question: say we have a simple for-loop as follows:
import time
for i in range(6):
x = i ** 1
time.sleep(5) #sleep for 5s
print(x)
While this loop is running (e.g. 11 s after we initiated the code), we decide to change/update x = i ** 1
to x = i ** 2
to get the output for the new x
. Is there any way to do this, i.e. manually updating the variable inside a loop while it's running (and obviously we do not want to use input
).
Thanks!