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 Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-nested-loops
Python Nested Loops - GeeksforGeeks
For example, a while loop inside a for loop, or a for loop inside another for loop. ... Outer_loop Expression: Inner_loop Expression: Statement inside inner_loop Statement inside Outer_loop ...
Published   4 days ago
Discussions

Nested While Loops
The following program is supposed to output numbered rows and columns (as in 1A, 1B, 1C, etc.) based on user input. If user enters 1 3, the output should be (1A 1B 1C). If the user enters 5C, the output should be (1A 1B 1C 2A 2B 2C 3A 3B 3C 4A 4B 4C 5A 5B 5C), etc. More on discuss.python.org
🌐 discuss.python.org
0
0
October 20, 2021
Is it bad to use a lot of nested while loops?
You could try splitting things out into functions to avoid nesting too deep in loops. More on reddit.com
🌐 r/learnpython
20
90
November 13, 2022
While/For/Nested Loops
Please format your code correctly so that it's legible. Whitespace matters in Python, so formatting matters when trying to help you out. There aren't any nested loops happening here. Can you correct your code formatting and try adding comments to explain what is happening line by line. More on reddit.com
🌐 r/learnpython
9
0
February 8, 2023
n00b trying to use nested while loops
The reason you've got an infinite loop is that you are using the equality operator == in some places where you need an assignment operator =. The former checks if two things are equal. The latter initializes or updates a variable. BTW, do you have to use a while loop here? Because the easiest way would be to use a for loop over the word and then check if a letter is a vowel with if letter in VOWELS: More on reddit.com
🌐 r/learnpython
6
1
December 12, 2022
🌐
Real Python
realpython.com › nested-loops-python
Nested Loops in Python – Real Python
February 22, 2025 - It goes through each first_id one by one while keeping track of its location using enumerate(). If any of the numbers in the list match, then you identify the number as a duplicate. More interestingly, you capture a clone. A solution to such a problem may be to forego nested loops in preference for more optimized techniques. In the example above, you could use a Python set or collections.Counter instead of nested loops.
🌐
Python.org
discuss.python.org › python help
Nested While Loops - Python Help - Discussions on Python.org
October 20, 2021 - The following program is supposed to output numbered rows and columns (as in 1A, 1B, 1C, etc.) based on user input. If user enters 1 3, the output should be (1A 1B 1C). If the user enters 5C, the output should be (1A 1B …
🌐
Tutorialspoint
tutorialspoint.com › python › python_nested_loops.htm
Python - Nested Loops
The following program uses a nested while loop to find the prime numbers from 2 to 100 − · i = 2 while(i < 25): j = 2 while(j <= (i/j)): if not(i%j): break j = j + 1 if (j > i/j) : print (i, " is prime") i = i + 1 print ("Good bye!")
🌐
Kansas State University
textbooks.cs.ksu.edu › intro-python › 05-loops › 08-nested-while
Nested While Loops :: Introduction to Python
June 27, 2024 - Resources Slides Up to this point, we explored how we can use iterative structures in our code, such as while loops and for loops, to repeat steps a certain number of times or while a Boolean condition is true. This is a very powerful tool, since it allows us to build programs that can repeatedly ...
Find elsewhere
🌐
ScholarHat
scholarhat.com › home
Loops in Python - For, While loop (With Examples)
September 10, 2025 - A nested loop in Python means using one loop inside another loop. It is commonly used when you need to repeat actions in a multi-level structure, like printing patterns or working with multi-dimensional lists (like 2D arrays). for iterating_var ...
🌐
PYnative
pynative.com › home › python › nested loops in python
Python Nested Loops [With Examples] – PYnative
September 2, 2021 - print('Show Perfect number fom 1 to 100') n = 2 # outer while loop while n <= 100: x_sum = 0 # inner for loop for i in range(1, n): if n % i == 0: x_sum += i if x_sum == n: print('Perfect number:', n) n += 1 Code language: Python (python) Run · Nested loops are handy when you have nested arrays or lists that need to be looped through the same function.
🌐
GeeksforGeeks
geeksforgeeks.org › python › loops-in-python
Loops in Python - GeeksforGeeks
... Note: It is suggested not to use this type of loop as it is a never-ending infinite loop where the condition is always true and we have to forcefully terminate the compiler. Python programming language allows to use one loop inside another loop ...
Published   February 14, 2026
🌐
OpenStax
openstax.org › books › introduction-python-programming › pages › 5-3-nested-loops
5.3 Nested loops - Introduction to Python Programming | OpenStax
March 13, 2024 - A program to print available appointments can use a nested for loop where the outer loop iterates over the hours, and the inner loop iterates over the minutes. This example prints time in hours and minutes in the range between 8:00am and 10:00am. In this example, the outer loop iterates over the time's hour portion between 8 and 9, and the inner loop iterates over the time's minute portion between 0 and 59. hour = 8 minute = 0 while hour <= 9: while minute <= 59: print(hour, ":", minute) minute += 30 hour += 1 minute = 0
🌐
Software Testing Help
softwaretestinghelp.com › home › python programming for beginners – free python tutorials › python loops – for, while, nested loops with examples
Python Loops - For, While, Nested Loops With Examples
April 1, 2025 - Answer: Python generally supports two types of loops: for loop and while loop. However, a third loop[nested loop] can be generated by nesting two or more of these loops.
🌐
W3Schools
w3schools.com › python › gloss_python_for_nested.asp
Python Nested Loops
Python Examples Python Compiler Python Exercises Python Quiz Python Challenges Python Server Python Syllabus Python Study Plan Python Interview Q&A Python Bootcamp Python Certificate Python Training ... A nested loop is a loop inside a loop.
🌐
Muzny
muzny.github.io › csci1200-notes › 06 › 5 › nested_whileloops.html
Nested While Loops
September 8, 2022 - In this case, we will “nest” our loops–put one loop inside of another loop. outer_loop_value = 0 while outer_loop_value < 10: print("Outer: " + str(outer_loop_value)) outer_loop_value += 1 inner_loop_value = 0 while inner_loop_value < ...
🌐
Real Python
realpython.com › lessons › nested-while-loops
Nested While Loops (Video) – Real Python
00:00 So while we are looking at this example, there’s actually one more thing we can talk about, and that’s the idea of having these nested conditional statements. 00:08 So, we have our while loop out here and inside of it, we have nested another conditional statement, an if statement.
Published   March 1, 2019
🌐
BigBinary Academy
courses.bigbinaryacademy.com › learn-python › while-loop › nested-while-loops
Nested While loops - Python | BigBinary Academy
We can also place a while loop within another while loop. This is also known as nesting a while loop. The program below multiplies every number of `numbers_list_1` with `numbers_list_2` using nested while loops.
🌐
TutorialKart
tutorialkart.com › python › python-while-loop › python-nested-while-loop
Python Nested While Loop - Examples
November 30, 2020 - Like three while loops one inside another. ... i = 1 while i <= 4 : j = 0 while j <= 3 : k = 0 while k <= 5 : print(i*j*k, end=" ") k += 1 print() j += 1 print() i += 1 ... 0 0 0 0 0 0 0 1 2 3 4 5 0 2 4 6 8 10 0 3 6 9 12 15 0 0 0 0 0 0 0 2 4 6 8 10 0 4 8 12 16 20 0 6 12 18 24 30 0 0 0 0 0 0 0 3 6 9 12 15 0 6 12 18 24 30 0 9 18 27 36 45 0 0 0 0 0 0 0 4 8 12 16 20 0 8 16 24 32 40 0 12 24 36 48 60 · In this Python Tutorial, we learned how to write Nested While Loops in Python.
🌐
Quora
quora.com › What-is-the-anatomy-of-a-nested-while-loop-in-Python
What is the anatomy of a “nested 'while-loop' in Python?
Answer (1 of 3): In my experience a common mis-understanding of while loops: [code]while condition1: Indented block of code that eventually causes condition1 to become false Code where execution will continue after the while loop terminates [/code]exists. The while doesn’t somehow co...
🌐
Medium
medium.com › @friedman.sydneyl › mastering-nested-while-loops-in-python-a-step-by-step-guide-9a0b30b01abd
Mastering Nested While Loops in Python: A Step-by-Step Guide | by Sydney Friedman | Medium
September 10, 2024 - Iterating through elements: We need to compare each number with every other number in the array. Loops are perfect for that. Checking combinations: We’re looking for pairs of numbers. That means using nested loops — one loop to pick the first number and another to check the rest.
🌐
Scientech Easy
scientecheasy.com › home › blog › nested loops in python
Nested Loops in Python - Scientech Easy
January 25, 2026 - Output: Outer while loop Inner while loop Inner while loop Outer while loop Nested while loops end here... a) In this example, initially, the counter variable x and y set with the value 1. b) Python first evaluates the outer while loop condition x < 3 to true.