Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23131

Why can't I put two while statements on top of each other?

$
0
0

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 timeclock = 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 += 1while 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.


Viewing all articles
Browse latest Browse all 23131

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>