Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

what is an indefinite loop

# 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 :: pandas group by to dataframe 
Python :: infinity range or infinity looping 
Python :: python randint with leading zero 
Python :: Python format() function uses. 
Python :: get center position of countries geopandas 
Python :: django.core.exceptions.ImproperlyConfigured: Field name is not valid for model 
Python :: python append many items to a list 
Python :: Python String index() 
Python :: punto1 
Python :: python change font in 1 line 
Python :: django creat app return _bootstrap._gcd_import 
Python :: how to hack instagram account using python 
Python :: shutdown thread python 
Python :: pandas form multiindex to column 
Python :: airflow find trigger type 
Python :: update python 
Python :: Define the learnable resizer utilities 
Python :: loop in coding 1.2 
Python :: python how to make item assignemnt class 
Python :: lib.stride_tricks.sliding_window_view(x, window_shape, axis=None, *, subok=False, writeable=False) 
Python :: How to know position on Kivy 
Python :: hack twitter with python 
Python :: with statement python 3 files 
Python :: rename_and_convert_all_images_at_folder 
Python :: nlp generate parse tree in python 
Python :: python get function from string name 
Python :: Ordering column names sensibly in pandas 
Python :: medium how to interact with jupyter 
Python :: addind scheduling of tasks to pyramid python app 
Python :: sns linear regression 
ADD CONTENT
Topic
Content
Source link
Name
2+1 =