list iteration in python code example

Example 1: list loop python

list = [1, 3, 5, 7, 9] 

# with index   
for index, item in enumerate(list): 
    print (item, " at index ", index)
    
# without index
for item in list:
  	print(item)

Example 2: python iterate list

lst = [10, 50, 75, 83, 98, 84, 32]
 
for x in range(len(lst)): 
    print(lst[x])

Example 3: iterate through a list

my_list = ["Hello", "World"]
for i in my_list:
  print(i)

Example 4: for loop in python array

for x in range (1, 100, 1):
  print(x)

Example 5: list iteration

>>> list('ATGC')
['A', 'T', 'G', 'C']

Example 6: python iterate list

lst = [12, 123, 1234, 12345]
for i in lst:
  print(i)
**********************result*********************
12
123
1234
12345

Tags:

Java Example