intro+for+loop
intro+for+loop
Variable string
Msg Array
H e l l o
Then again it repeats using for and prints the next letter
X
H e
✓
x
H e
l
✓
It goes on repeating till the end of an array
This loop is also called as foreach loop in languages like java
and c++
Msg=’hello’
For x in msg:#for loop runs for each statement in the sequence
(print x)
Flow chart(for loop)
True
For I in Body of for
range(0,10)
false
• Start End
• Can also give step range(1,10,2) 1,3,5,7,9
For i in range(0,10):
Print(i)
0 1 2