Python 3 For loop. | pycoder

python3 For loop.

For Loop are used for sequential traversal. For example: traversing a list or string or array etc. In Python, there is no C style for loop, i.e., for (i=0; i<n; i++). There is "for in" loop which is similar to for each loop in other languages. Let us learn how to use for in loop for sequential traversals.

Syntax:

for iterator_var in sequence:
      statements(s)

example:

for i in range (1,11):          
     print (i)                         

Output:

>>>                             
1                                   
2                                   
3                                   
4                                   
5                                   
6                                   
7                                   
8                                   
9                                   
10                                 


Any type of problem using to for loop please check my video


No comments:

Powered by Blogger.