loop through a list code example
Example 1: iterate through a list
my_list = ["Hello", "World"]
for i in my_list:
print(i)
Example 2: traversal of list in java
import java.util.ArrayList;
import java.util.Iterator;
public class IteratorSample {
public static void main(String[] args) {
ArrayList<String> list = new ArrayList<String>();
list.add("JavaFx");
list.add("Java");
list.add("WebGL");
list.add("OpenCV");
Iterator iterator = list.iterator();
while(iterator.hasNext()) {
System.out.println(iterator.next());
}
}
}
Example 3: how to iterate over a list in python
lst = [10, 50, 75, 83, 98, 84, 32]
res = list(map(lambda x:x, lst))
print(res)
Example 4: python iterate list
lst = [12, 123, 1234, 12345]
for i in lst:
print(i)
**********************result*********************
12
123
1234
12345