How to Use For loop List Option Quickly
For loop is main concept in Python programming. Out of all the For Loop options, the list option is so popular. If you know, how to use this concept, you can write any number of programs quickly and with less effort.
Using for loop you can get index for list items. You can print list elements using for loop.
If you take any language, the loops play a vital role.
The 'i' says variable that represents value in the 'my_list'. The for helps to iterate the list values one by one.
Example Program For Loop List in Python
Result
Using for loop you can get index for list items. You can print list elements using for loop.
If you take any language, the loops play a vital role.
How to Use For Loop
When you want to deal with data of multiple values, you need loops. So, For Loop is so famous because, you can control multiple input values.Syntax to Write For Loop
for i in my_list:
print(i)
The 'i' says variable that represents value in the 'my_list'. The for helps to iterate the list values one by one.
Example Program For Loop List in Python
my_list=[2,3,4]
for i in my_list:
print(i)
Result
2
3
4
How to create Multiplication Table using Python For-Loop List Option.
Function to create table |
Result of function that generated Multiplication Table
Creating multiplication table in python |
Bottom Line
- You can use for loop to calculate Factorial and listing values one by one.
- Your input data contains multiple values, then For loop is so useful.
Comments
Post a Comment
Thanks for your message. We will get back you.