diff --git a/guide/english/python/for-loop-statements/index.md b/guide/english/python/for-loop-statements/index.md index 6efeca7dcb..4939152a60 100644 --- a/guide/english/python/for-loop-statements/index.md +++ b/guide/english/python/for-loop-statements/index.md @@ -22,6 +22,14 @@ list_of_tuples = [(1,2), (3,4)] for a, b in list_of_tuples: print("a:", a, "b:", b) ``` +Output: + +```python +a: 1 b: 2 +a: 3 b: 4 +``` + + On the other hand, you can loop over anything that is iterable. You can call a function or use a list literal. ```python @@ -34,6 +42,17 @@ for character in ["P", "y", "t", "h", "o", "n"]: print("Give me a '{}'!".format(character)) ``` +Output: + +```python +Give me a 'P'! +Give me a 'y'! +Give me a 't'! +Give me a 'h'! +Give me a 'o'! +Give me a 'n'! +``` + Some ways in which For loops are used: **Iterate over the range() function** @@ -44,6 +63,7 @@ for i in range(10): ``` Rather than being a function, range is actually an immutable sequence type. The output will contain results from lower bound i.e 0 to the upper bound i.e 10 but excluding 10.By default the lower bound or the starting index is set to zero. + Output: ```