changes to grammar and punctuation (#28353)
This commit is contained in:
committed by
Randell Dawson
parent
0a03967faa
commit
726b1da739
@ -3,7 +3,7 @@ title: For Loop Statements
|
||||
---
|
||||
## For Loop Statements
|
||||
|
||||
Python utilizes a for loop to iterate over a list of elements. Unlike C or Java, which use the for loop to change a value in steps and access something such as an array using that value.
|
||||
Python utilizes a for loop to iterate over a list of elements. This is different to C or Java, which use the for loop to change a value in steps and access something such as an array using that value.
|
||||
|
||||
For loops iterate over collection based data structures like [lists](https://github.com/freeCodeCamp/freeCodeCamp/tree/master/guide/english/python/lists), tuples, and dictionaries.
|
||||
|
||||
@ -29,7 +29,6 @@ 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
|
||||
@ -61,8 +60,7 @@ Some ways in which For loops are used:
|
||||
for i in range(10):
|
||||
print(i)
|
||||
```
|
||||
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.
|
||||
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:
|
||||
|
||||
|
Reference in New Issue
Block a user