I am fairly new to python, so this is probably a beginner mistake, but depending on how I order the while statements, it either doesn't load, or doesn't update time.
import time
clock = 0
Basically, when I put the while statements in this order, the code actually runs, but the second while statement never activates.
while 1<2:
x = inpu(input('What do you want to do?'));
if x == "time":
print(clock)
else:
print(x)
while 2<4:
time.sleep(5)
clock += 1
When I put the while statements like this, the code just doesn't run.
while 2<4:
time.sleep(5)
clock += 1
while 1<2:
x = inpu(input('What do you want to do?'));
if x == "time":
print(clock)
else:
print(x)
I didn't go into detail about inpu()
, but it basically says, if you type ___ in the input, it will respond with ___. One of those options is "clock", which will print the clock value.
When I removed everything from the small while statement when it was ontop(replaced everything with a pass
), the code still wouldn't run. So it isn't a problem with the contents of the second while statement, but most likely the fact that there are two.
source https://stackoverflow.com/questions/77784167/why-cant-i-put-two-while-statements-on-top-of-each-other
Comments
Post a Comment