Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to end a while loop python

while True:
    x = input('Enter something 
')
    if x == "TTYL":
        print("Talk to you later")
        break <--- Key word
Comment

python how to end while loop

# a 'while' loop runs until the condition is broken
a = "apple"
while a == "apple":
  a = "banana" # breaks loop as 'a' no longer equals 'apple'
  
# a 'for' loop runs for the given number of iterations...
for i in range(10):
  print(i) # will print 0, 1, 2, 3, 4, 5, 6, 7, 8, 9

# ... or through a sequence
array = [3, 6, 8, 2, 1]
for number in array:
  print(number) # will print 3, 6, 8, 2, 1
Comment

PREVIOUS NEXT
Code Example
Python :: numpy dataframe 
Python :: intialize 2d aray in python 
Python :: are tuples in python mutable 
Python :: NumPy roll Example 
Python :: Python Generators with a Loop 
Python :: how to iterate through a list of numbers in python 
Python :: python count elements in sublists 
Python :: pandas rearrange rows based on datetime index 
Python :: pip install 
Python :: python requests insecure request warning 
Python :: read one column pandas 
Python :: sqlite python select with parameters 
Python :: float python 
Python :: import one file into another python 
Python :: protected class python 
Python :: python get parent class 
Python :: try and except in python 
Python :: how to use re.sub 
Python :: load list from file python 
Python :: How to Replace substrings in python 
Python :: qr decomposition python 
Python :: return function in python 
Python :: inheritance in python 3 example 
Python :: python count how many times a word appears in a string 
Python :: save variable to use in other jupyter notebook 
Python :: adding numbers in python 
Python :: import user model 
Python :: conv2d default stride 
Python :: how to avoid inserting duplicate records in orm django 
Python :: opening a file in python 
ADD CONTENT
Topic
Content
Source link
Name
1+8 =