list foreach py code example
Example 1: iterate through an array python
colors = ["red", "green", "blue", "purple"]
i = 0
while i < len(colors):
print(colors[i])
i += 1
Example 2: py foreach
// PHP:
foreach ($array as $val) {
print($val);
}
// C#
foreach (String val in array) {
console.writeline(val);
}
// Python
for val in array:
print(val)