Answers for "foreach python"

54

python loop through list

list = [1, 3, 6, 9, 12] 
   
for i in list: 
    print(i)
Posted by: Guest on June-25-2019
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)
Posted by: Guest on June-26-2020
1

py foreach

names = ['tom', 'john', 'simon']

namesCapitalized = [capitalize(n) for n in names]
Posted by: Guest on June-26-2020
1

for each loop python 3

# 'foreach' in python is done using 'for'
for val in array:
    print(val)
Posted by: Guest on January-28-2020
1

foreach loop in python

# Python doesn't have a foreach statement per se. 
# It has for loops built into the language. 
# As a side note the for element in iterable syntax comes from 
# the ABC programming language, one of Python's influences
Posted by: Guest on November-18-2020

Python Answers by Framework

Browse Popular Code Answers by Language