The for loop you need is to print the data you want usually multiple times. For loop, is having two arguments such as variable name and in. I have also given video example in the bottom.
In Python for loop list and count are related to same logic. In the below example, I have taken one array or list, and I counted using for loop, the number of elements in this list
For loop Syntax
First step, How the above syntax works is what I want to share with you. The 'in' represents input array for Python for loop. That means the for loop works 3 times in Python. It displays only 3 times. The third step is just give 'yes', which will multiply with 'count' for 3 times.
for count in[1, 2, 3]: print(count) print(’Yes’*count)
This is whole story of for loop in Python. Second step, print just displays values of input that stored in the for loop variable of 'count'.
The 'count' gets values one by one from for loop input array.When you used the Shell to enter a loop, there was a reason that the interpreter waited to respond until after you entered an empty line: The interpreter did not know how long the loop block was going to be! The empty line is a signal tothe interpreter that you are done with the loop block.
Index in For loop
A small example given to get index and value from for loop.
#Get index using for loop #You will get index and value mylist=[1, 2, 3]:
for idx, val in enumerate(mylist): print(idx, val)
I have created a small video, so that you can play quickly and check how for loop works in Python.