while if else python code example
Example 1: infinite while python
#infinite While on Python
while True:
print('Hello World!')
Example 2: while else python
target = 100
current = 0
while current != target:
current += 1
print(current)
#The while loop repeats the indented code while its condition is true
#(current IS NOT equal to target).
else:
print("Target Reached!")
#When the while loop condition is no longer true (current IS equal to target),
#the indented code under else: is ran.