Guide to Python : For Loop
JohnStarrs (22)

This is apart of the Guide to Python that ive been making for new users,
if you find this useful let me know.
If you need more guides check my account out as ive made a few so you can hopefully learn this amazing language of coding

Enjoy =)

An for loop is one of the few loops we have within Python.
These loops are easy to learn and code and as an added bonus they have a built in counter.
This is how it looks like :

for i in range():

Note the print can be changed to whatever function you like

Inside the () of the for loop you include the number of loops
For this example we will use 4 loops
To do this we start at 0 (because this is really 1 and not 0)
So we get :

for i in range(0,4)

You can also use the input feature to allow the user to select the amount of loops
it would look as :

x = int(input())
for i in range(0,x)

If you want we can use len() as well

y = input()
for i in range(0,len(y))

And that's the for loop for more detail look through the code as that explains the for loop as well

For more check the code in itself
or check my account for more guides to Python

You are viewing a single comment. View All
JohnStarrs (22)

@theangryepicbanana kk, but isnt it more useful having it in the code itself incase they want to fork it?