for each python fn code example
Example 1: 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)
Example 2: py foreach
names = ['tom', 'john', 'simon']
namesCapitalized = [capitalize(n) for n in names]
Example 3: for each loop python 3
# 'foreach' in python is done using 'for'
for val in array:
print(val)