From e929a31bc02401f11a39c8e0ddc599cac12ba40c Mon Sep 17 00:00:00 2001 From: ankesh292 <40523848+ankesh292@users.noreply.github.com> Date: Thu, 20 Dec 2018 07:53:10 +0530 Subject: [PATCH] Update index.md (#33467) --- .../python/for-loop-statements/index.md | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/guide/english/python/for-loop-statements/index.md b/guide/english/python/for-loop-statements/index.md index 01a1c697a4..df11714e62 100644 --- a/guide/english/python/for-loop-statements/index.md +++ b/guide/english/python/for-loop-statements/index.md @@ -250,6 +250,30 @@ A interesting fact is that for loop is a bit faster compared to while loop in py https://stackoverflow.com/questions/869229/why-is-looping-over-range-in-python-faster-than-using-a-while-loop +**Nested Loops** + +A nested loop is a loop inside a loop. + +The "inner loop" will be executed one time for each iteration of the "outer loop": + +```python +var = ["Hey", "How"] +name = ["ram", "shyam"] + +for x in var: + for y in name: + print(x, y) +``` + +Output: +``` +> +Hey ram +Hey shyam +How ram +How shyam +> +``` #### More Information: - Python2 for loop documentation