Loops in python
Have you ever felt like you are doing certain tasks again and again in life?
Well, I’m no expert in helping with your life!
Although, if you would ever face the same situation in a programming language I can help you with that.
In programming, we can repeat certain tasks using loops.
Let’s go through them one by one.
for
loop
for
loop in python repeats over each item of a given sequence (a list or a string), in the order that they appear in the sequence.
Example:
Output:
I want to watch a movie directed by James Cameron
I want to watch a movie directed by Christopher Nolan
I want to watch a movie directed by Steven Spielberg
- But, let’s say you are a programmer who needs to iterate over a sequence of numbers, given the limit you want. Well, then you can make use of the built-in function range() which generates arithmetic progressions:
Output:
0
1
2
3
4
while loop
while
loop in python repeats any given set of code until the given condition returns true.
Example:
Output:
0
1
1
2
3
5
8
Who Am I?
I’m Aswin Barath, a Software Engineering Nerd who loves building Web Applications, now sharing my knowledge through Blogging and Community events during the busy time of my freelancing work life.
Here’s the link to all of my craziness categorized by platforms under one place: https://linktr.ee/AswinBarath
For my blog lovers, read more Bite-sized Medium articles from our FB Page on Software Concepts, New & Trending Technologies. We provide a “Friend Link” 🤝 that guarantees anyone free access to our story, even if they’ve read all of their complimentary stories for this month 😍
Join me to learn Python!
Checkout the TechSoftware Feature Page where my mission is to share my knowledge on Python: https://medium.com/techsoftware/python/home
Learn what I know about Python from any of my favourite knowledge sources:
- Python Programming: A Beginner’s Guide
- FreeCodeCamp Scientific Computing with Python
- Complete Python Developer Course
- Junior to Senior Developer Course
Keep Learning
Now, I guess this is where I say GoodBye👋.
But, hey it’s time for you to start learning with your newfound Knowledge(Power)👨💻👩💻 .
Good Job that you made it this far 👏👏
Thank you so much for reading my Blog🙂.
Also published at https://aswinbarath.tech