for
statement iterates over each item of a sequence.
Examples of sequences:
- Sequence of Characters (string)
- Sequence of numbers, etc.
For Syntax
Code
PYTHON
Output
Range
Generates a sequence of integers starting from 0. Syntax:
range(n)
Stops before n (n is not included).Code
PYTHON
Output
Range with Start and End
Generates a sequence of numbers starting from
start
Syntax:
range(start, end)
Stops before end
(end is not included). Code
PYTHON