“Foreach Loop in Python” Code-Antworten

Für jede Schleife Python 3

# 'foreach' in python is done using 'for'
for val in array:
    print(val)
QuietHumility

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)
Crazy Copperhead

py foreach

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

namesCapitalized = [capitalize(n) for n in names]
Crazy Copperhead

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
mrhm.dev

Ähnliche Antworten wie “Foreach Loop in Python”

Fragen ähnlich wie “Foreach Loop in Python”

Weitere verwandte Antworten zu “Foreach Loop in Python” auf Python

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen