Not sure what your problem is, maybe you want to put that x=0 right before the inner loop ?
Your whole code doesn't look remotely like Python code ... loops like that are better done like this:
for b in range(0,11):
print 'here is the outer loop',b
for x in range(0, 16):
#k=p[x]
print 'here is the inner loop',x
Answer from Jochen Ritzel on Stack OverflowNot sure what your problem is, maybe you want to put that x=0 right before the inner loop ?
Your whole code doesn't look remotely like Python code ... loops like that are better done like this:
for b in range(0,11):
print 'here is the outer loop',b
for x in range(0, 16):
#k=p[x]
print 'here is the inner loop',x
Because you defined the x outside of the outer while loop its scope is also outside of the outer loop and it does not get reset after each outer loop.
To fix this move the defixition of x inside the outer loop:
b = 0
while b <= 10:
x = 0
print b
while x <= 15:
print x
x += 1
b += 1
a simpler way with simple bounds such as this is to use for loops:
for b in range(11):
print b
for x in range(16):
print x
Nested While Loops
Is it bad to use a lot of nested while loops?
While/For/Nested Loops
n00b trying to use nested while loops
Videos
I'm writing some cli program for a course I'm following and I find myself using a lot of "while 1" statements. I use them for input validation along with try/catch blocks.
Is it bad practice to abuse those while loops ?