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
🌐
Kansas State University
textbooks.cs.ksu.edu › intro-python › 05-loops › 08-nested-while
Nested While Loops :: Introduction to Python
June 27, 2024 - When we run this code, each time we execute the steps inside of the outer while loop, we’ll have to completely go through the inner while loop as well. It can be very complex to keep track of everything, but with a bit of practice we’ll learn some strategies for mentally working through loops. Before continuing, take a look at that program’s code and see if you can determine what it will print! To really understand how a set of nested loops work, let’s go through a code tracing example using Python Tutor.
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
October 4, 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 11, 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 15, 2022
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-nested-loops
Python Nested Loops - GeeksforGeeks
After that run an outer for loop to iterate over list1 and inside that loop run an inner while loop to iterate over list2 using list indexing inside that we are printing each value of list2 for every value of list1.
Published   July 23, 2025
🌐
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.
🌐
Tutorialspoint
tutorialspoint.com › python › python_nested_loops.htm
Python - Nested Loops
The following program uses a nested ... jan tue feb sun feb mon feb tue mar sun mar mon mar tue Good bye! The while loop having one or more inner while loops are nested while loop....
🌐
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   1 month ago
🌐
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 - However, a third loop[nested loop] can be generated by nesting two or more of these loops. Looping statements in python are used to execute a block of statements or code repeatedly for several times as specified by the user.
Find elsewhere
🌐
W3Schools
w3schools.com › python › gloss_python_for_nested.asp
Python Nested Loops
Python Dictionaries Access Items Change Items Add Items Remove Items Loop Dictionaries Copy Dictionaries Nested Dictionaries Dictionary Methods Dictionary Exercises Code Challenge Python If...Else · Python If Python Elif Python Else Shorthand If Logical Operators Nested If Pass Statement Code Challenge Python Match ... Python Functions Python Arguments Python *args / **kwargs Python Scope Python Decorators Python Lambda Python Recursion Python Generators Code Challenge Python Range ... Matplotlib Intro Matplotlib Get Started Matplotlib Pyplot Matplotlib Plotting Matplotlib Markers Matplotlib Line Matplotlib Labels Matplotlib Grid Matplotlib Subplot Matplotlib Scatter Matplotlib Bars Matplotlib Histograms Matplotlib Pie Charts
🌐
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 1C 2A 2B 2C 3A 3B 3C ...
🌐
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
🌐
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
Nested Loops in Python
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.
🌐
CodeSpeedy
codespeedy.com › home › nested while loops in python with examples
Nested While Loops In Python With Examples - CodeSpeedy
May 12, 2022 - Next, the inner while loop condition is evaluated. If it is false then control jumps back to the outer while loop condition. If it is true, then the block of code inside the inner while loop is executed. In this example, we create a pattern of numbers using a nested while loop
🌐
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.
🌐
GeeksforGeeks
geeksforgeeks.org › loops-in-python
Loops in Python - For, While and Nested Loops - GeeksforGeeks
Python programming language allows to use one loop inside another loop which is called nested loop. Following section shows few examples to illustrate the concept. for iterator_var in sequence: for iterator_var in sequence: statements(s) statements(s) The syntax for a nested while loop statement in the Python programming language is as follows:
Published   March 8, 2025
🌐
EyeHunts
tutorial.eyehunts.com › home › nested while loop in python | example code
Nested while loop in Python | Example code
June 21, 2023 - The program will continue execution until either the inner condition or the outer condition evaluates to False, terminating the respective loop. Remember to modify the code according to your specific requirements and conditions. Simple example code. i = 1 j = 5 while i < 4: while j < 8: print(i, ",", j) j = j + 1 i = i + 1 ... Display multiplication table using nested while in Python language.
🌐
Toppr
toppr.com › guides › computer-science › introduction-to-python › conditional-constructs-and-looping › nested-loops
Nested Loops: Python Nested Loops, Nested for Loop Syntax, FAQs
May 21, 2021 - Further, the first pass of the ... the inner loop again. ... Answer 2: A nested while loop is basically a while statement inside another while statement....
🌐
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.