Skip to main content

Python For Loop Example: This Is What Professionals Do

python loops

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

for count in[1, 2, 3]: 
print(count)
print(’Yes’*count)
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.

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)

Video Tutorial

I have created a small video, so that you can play quickly and check how for loop works in Python.
Also read

Comments

Popular posts from this blog

Blue Prism complete tutorials download now

Blue prism is an automation tool useful to execute repetitive tasks without human effort. To learn this tool you need the right material. Provided below quick reference materials to understand detailed elements, architecture and creating new bots. Useful if you are a new learner and trying to enter into automation career.
The number one and most popular tool in automation is a Blue prism. In this post, I have given references for popular materials and resources so that you can use for your interviews.
Why You Need to Learn RPA blue prism tutorial popular resources I have given in this post. You can download quickly. Learning Blue Prism is a really good option if you are a learner of Robotic process automation.
RPA Advantages The RPA is also called "Robotic Process Automation"- Real advantages are you can automate any business process and you can complete the customer requests in less time.

The Books Available on Blue Prism 
Blue Prism resourcesDavid chappal PDF bookBlue Prism…

Topologies in Apache Storm the concept you need to know

There are two main reasons why Apache Storm is so popular. The number one is it can connect to many sources. The number two is scalable. The other advantage is fault tolerant. That means, guaranteed data processing.
The map-reduce jobs process the data analytics in Hadoop. The topology in Storm is the real data processor. The co-ordination between Nimbus and Supervisor carried by Zookeeper What are topologiesThe jobs in Hadoop are similar to topology. The jobs run as per schedule defined.In Storm, the topology runs forever.A topology consists of many worker processes spread across many machines. A topology is a pre-defined design to get end product using your data.A topology comprises of 2 parts. These are Spout and bolts.The Spout is a funnel for topology Two nodes in StormMaster Node: similar to Hadoop job tracker. It runs on a daemon called Nimbus.Worker Node: It runs on a daemon called Supervisor. The Supervisor listens to the work assigned to each machine.Master NodeNimbus is re…

Three popular RPA tools functional differences

Robotic process automation is growing area and many IT developers across the board started up-skill in this popular area. I have written this post for the benefit of Software developers who are interested in RPA also called Robotic Process Automation.

In my previous post, I have described that total 12 tools are available in the market. Out of those 3 tools are most popular. Those are Automation anywhere, BluePrism and Uipath. Many programmers asked what are the differences between these tools. I have given differences of all these three RPA tools.

BluePrismBlue Prism has taken a simple concept, replicating user activity on the desktop, and made it enterprise strength. The technology is scalable, secure, resilient, and flexible and is supported by a comprehensive methodology, operational framework and provided as packaged software.The technology is developed and deployed within a “corridor of IT governance” and has sophisticated error handling and process modelling capabilities to ensu…