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
Nested While Loops
While/For/Nested Loops
Is it bad to use a lot of nested while loops?
Videos
Could someone provide me with a link for nested while loops so I can understand them better? I have read about them and I also practiced them, however I find them hard to understand how they are supposed to function.