Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

indefinite loops

# There are 2 types of loops in python
# while loops and for loops
# a while loops continues for an indefinite amount of time
# until a condition is met:

x = 0
y = 3
while x < y:
    print(x)
    x = x + 1

>>> 0
>>> 1
>>> 2

# The number of iterations (loops) that the while loop above
# performs is dependent on the value of y and can therefore change

######################################################################

# below is the equivalent for loop:
for i in range(0, 3):
    print(i)

>>> 0
>>> 1
>>> 2

# The for loop above is a definite loop which means that it will always
# loop three times (because of the range I have set)
# notice that the loop begins at 0 and goes up to one less than 3.
Comment

PREVIOUS NEXT
Code Example
Python :: indefinite loops python 
Python :: commands.has_role discord.py 
Python :: python program to find sum of array elements 
Python :: flask echo server 
Python :: spreadsheet worksheet counter 
Python :: string contains element of list python 
Python :: replace NaN value in pandas data frame with zeros 
Python :: create tab in python text 
Python :: Search for a symmetrical inner elements of a list python 
Python :: python nasa api 
Python :: Delete all small Latin letters a from the given string. 
Python :: how to write a first program in machine learning 
Python :: python russian roulette 
Python :: print A to Z in python uppercase 
Python :: python zeromq timeout 
Python :: flask base __init__.py file 
Python :: convolutional layer of model architecture pass input_shape 
Python :: python pytest use same tests for multiple modules 
Python :: tekinter python 
Python :: is 2 an even number 
Python :: pool.map multiple arguments 
Python :: ipython run script with command line arguments 
Python :: python remove title from name 
Python :: series clip 
Python :: Insert Multiple Images to Excel with Python 
Python :: lekht valenca poland 
Python :: duplicate finder python modules 
Python :: is Cross policy an issue with puppeteer / headless chrome? 
Python :: nlp.Defaults.stop_words.add spacy 
Python :: left rotation in list 
ADD CONTENT
Topic
Content
Source link
Name
1+1 =