for i loops python code example

Example 1: python for loop

for x in (list):
  print(x)

Example 2: for in python

# how to use for in python for (range, lists)
fruits = ["pineapple","apple", "banana", "cherry"]
for x in fruits:
  if x == "apple":
    continue
  if x == "banana":
    break
  print(x)
# fron 2 to 30 by 3 step
for x in range(2, 30, 3):
  print(x)

Example 3: python for loop

nums = ['one', 'two', 'three']
for elem in nums:
  print(elem)

Example 4: python for loop

//x starts at 1 and goes up to 5 increasing by 2
for x in range(1,5,2):
  print(x)