HOME/Articles/

loops

Article Outline

Example Python program loops.py Python version 3.x or newer. To check the Python version use:

python --version

Code

Python example

users = ['user#1','user#2','user#3','user#4','user#5']
arrayLetterByLetter = list('edwin')

for user in users:
  print('Hello there '+user)

# 0 1 2 3 ... 100  
my_list = list(range(0, 100)

# 0 5 10 ... 90 95 100
my_list = list(range(0, 100, 5))

for i in range(0, 20):
     print('I run 20 times')

for letter in name:
     print(letter)

age = 10
# While age + 10
while age < 100:
       print('yahhh')
    age += 1
    if(age == 14):
        continue
        print('I am independent now')

    if(age == 14):
       print('this time break') 
       break


# While loop
while True:
    print('I am running')