Recent Posts

For Loops



A for loop is used for iterating over a sequence (that is either a list, a tuple, a dictionary, a set, or a string).
This is less like the for keyword in another programming language and works more like an iterator method as found in other object-orientated programming languages.

With the for loop we can execute a set of statements, once for each item in a list, tuple, set etc.

The collection could be a string, a range, a list, anything that has multiple items

It can be done with each character in a string..For example, we are going to call a Variable Item




Now let's put for example the 3 wise men in the variable


Or a sequence of numbers

We can use a range of number
It will start with 0 but 5 is not included



In the next case, it will jump 2 steps forward




We will make an application that calculates our shopping car


But with Augmented assignment operator, total= total + price becomes total +=price







For Loops For Loops Reviewed by ohhhvictor on May 06, 2019 Rating: 5

No comments:

Facebook

 photo imagen120.jpg
Theme images by 5ugarless. Powered by Blogger.