Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

indefinite loops python

# 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 :: Facet Grid for Bar Plot with non-shared y axes (CatPlot) 
Python :: add user agent selenium python canary 
Python :: subtract constant from list 
Python :: web3.py failing not installing 
Python :: Python - How To Pad String With Spaces 
Python :: zipfile python unzip with path 
Python :: asyncioevents.py", line 504, in add_reader raise NotImplementedError 
Python :: add variable to print python 
Python :: display list 
Python :: list generation for python 
Python :: django snippet 800 
Python :: landscape odoo report 
Python :: pandas math operation from string 
Python :: Spatial Reference arcpy 
Python :: python print over the same line 
Python :: how to send message to specific channel discord/py 
Python :: ublox kismet 
Python :: flask example 
Python :: Make Latest pyhton as default in mac 
Python :: python download from digital ocean spaces boto3 
Python :: menampilkan data dalam range tertentu di python 
Python :: module django contrib admin has no attribute action ACTION_CHECKBOX_NAME 
Python :: scipy random seed 
Python :: type operator in python 
Python :: how to keep old content when using write in python 
Python :: jet 4 access python password 
Python :: ler arquivo xls no pandas 
Python :: par e impar pygame 
Python :: how to format a matrix to align all rows python 
Python :: Warning message: In scan(file = file, what = what, sep = sep, quote = quote, dec = dec, : EOF within quoted string 
ADD CONTENT
Topic
Content
Source link
Name
2+3 =