Every occurence of "foreach" I've seen (PHP, C#, ...) does basically the same as pythons "for" statement.

These are more or less equivalent:

// PHP:
foreach ($array as $val) {
    print($val);
}

// C#
foreach (String val in array) {
    console.writeline(val);
}

// Python
for val in array:
    print(val)

So, yes, there is a "foreach" in python. It's called "for".

What you're describing is an "array map" function. This could be done with list comprehensions in python:

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

namesCapitalized = [capitalize(n) for n in names]
Answer from Jo Are By on Stack Overflow
๐ŸŒ
Real Python
realpython.com โ€บ python-for-loop
Python for Loops: The Pythonic Way โ€“ Real Python
1 month ago - The for loop syntax declares a loop variable that takes each item from the collection in each iteration. This loop is ideal for repeatedly executing a block of code on each item in the collection.
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ python_for_loops.asp
Python For Loops
Python Examples Python Compiler ... Python Training ... A for loop is used for iterating over a sequence (that is either a list, a tuple, a dictionary, a set, or a string). This is less like the for keyword in other programming languages, and ...
Discussions

Why does Python forces you to use "For" instead of "For Each" but lets you use "char" and "character"?
Neither char nor character are keywords in the language. If you were using it in a loop, like for char in word , well, that could have been anything. for spongebob in word would do the same, because your loop variable is assigned as if it were a name on the left of an equals. More on reddit.com
๐ŸŒ r/learnpython
35
0
December 12, 2024
for loops are confusing
What exactly is the issue you are having?? list1 = ['physics', 'chemistry', 1997, 2000]; for EachItem in list1: print(EachItem) More on reddit.com
๐ŸŒ r/learnpython
8
3
March 20, 2021
Why does the "for" loop work so different from other languages like Java or C++ .
Language designer decision. More of a for each than a traditional for but still fundamentally a while loop with some of the work done for you. More on reddit.com
๐ŸŒ r/learnpython
70
169
February 16, 2022
Having hard time understanding for loops in python

range(n) returns a sequence of numbers.

"for A in B" iterates over B. A being the name you use to refer to the current item being iterated upon.

More on reddit.com
๐ŸŒ r/learnprogramming
13
1
June 13, 2022
๐ŸŒ
Python
wiki.python.org โ€บ moin โ€บ ForLoop
ForLoop - Python Wiki
for loops are used when you have a block of code which you want to repeat a fixed number of times. The for-loop is always used in combination with an iterable object, like a list or a range. The Python for statement iterates over the members of a sequence in order, executing the block each time.
๐ŸŒ
IBM
ibm.com โ€บ reference โ€บ python โ€บ for-loop
What is a for loop in python? | IBM
November 21, 2025 - In essence, a for loop is designed to move to the next element in the sequence after each iteration, ensuring that each item is processed. In Python, the for loop is a versatile tool.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ loops-in-python
Loops in Python - GeeksforGeeks
The main types are For loops (counting through items) and While loops (based on conditions). For loops is used to iterate over a sequence such as a list, tuple, string or range. It allow to execute a block of code repeatedly, once for each item ...
Published ย  1 week ago
๐ŸŒ
Mimo
mimo.org โ€บ glossary โ€บ python โ€บ for-loop
Python For Loop: Syntax and Examples [Python Tutorial]
In this example, the loop iterates over the list of numbers with a starting value of 1. Each iteration assigns the current value from the sequence of numbers to number. The function call in the code block prints each number in the list. range() is a built-in function that creates a list of numbers starting at 0 and stopping before a specified integer. This makes the range function ideal for creating Python for loops with index variables.
Find elsewhere
๐ŸŒ
Programiz
programiz.com โ€บ python-programming โ€บ for-loop
Python for Loop (With Examples)
Python in the second iteration. Go in the third iteration. ... The for loop iterates over the elements of sequence in order, and in each iteration, the body of the loop is executed.
๐ŸŒ
Imperialcollegelondon
imperialcollegelondon.github.io โ€บ python-novice-mix โ€บ 07-for-loops โ€บ index.html
Programming in Python: For Loops
November 8, 2018 - Write for loops that use the ... as working with pressure_001, pressure_002, etc. A for loop tells Python to execute some statements once for each value in a list, a character string, or some other collection....
๐ŸŒ
Data Science Discovery
discovery.cs.illinois.edu โ€บ learn โ€บ Simulation-and-Distributions โ€บ For-Loops-in-Python
For-Loops in Python - Data Science Discovery
The variable i will take on each of these each time it goes through the loop. Even if we never use i, it's still required syntax in our for-loop. # Notice the use of `range(17)` to run this code 17 times:\nfor i in range(17):\n print(i) ... Ten cards randomly drawn (with replacement) using a for-loop. When we discussed generating Random Numbers in Python, we explored generating 100 rolls of a six-sided die.
๐ŸŒ
Python documentation
docs.python.org โ€บ 3 โ€บ tutorial โ€บ controlflow.html
4. More Control Flow Tools โ€” Python 3.14.3 documentation
If the loop finishes without executing the break, the else clause executes. In a for loop, the else clause is executed after the loop finishes its final iteration, that is, if no break occurred.
๐ŸŒ
Sentry
sentry.io โ€บ sentry answers โ€บ python โ€บ accessing the index in a `for` loop in python
Accessing the Index in a `for` Loop in Python | Sentry
November 22, 2022 - So rather than saying โ€œdo this n timesโ€, a foreach loop essentially says โ€œdo this to everything in the sequenceโ€. For scenarios where we actually need the index or counter variable, we can use Pythonโ€™s built-in enumerate function. The enumerate function returns an iterable. Each element of this iterable is a tuple containing the index of the item and the original item value, like so:
๐ŸŒ
Stanford CS
cs.stanford.edu โ€บ people โ€บ nick โ€บ py โ€บ python-for.html
For Loop
Sometimes programmers feel they ... see an assignment with an equal sign = The for-loop is different, since for each iteration, the loop sets the variable to point to the next value....
๐ŸŒ
Dataquest
dataquest.io โ€บ blog โ€บ python-for-loop-tutorial
Python for Loop: A Beginner's Tutorial โ€“ Dataquest
March 10, 2025 - In most data science tasks, Python ... a time. During each iteration (i.e., each pass of the loop), Python updates an iteration variable to represent the current item, which you can then use within the loop's code block...
๐ŸŒ
Dataquest
dataquest.io โ€บ blog โ€บ tutorial-advanced-for-loops-python-pandas
Tutorial: Advanced Python for Loops โ€“ Dataquest
March 11, 2025 - In the code below, we'll write a for loop that iterates through each element by passing z, our two-dimensional array, as the argument for nditer(): ... As we can see, this first lists all of the elements in x, then all elements of y. Remember! When looping through these different data structures, dictionaries require a method, NumPy arrays require a function. When we're working with data in Python, we're often using pandas DataFrames.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ python-foreach-how-to-program-in-python
Python Foreach - How to Implement ? - GeeksforGeeks
April 26, 2025 - Foreach loop is a convenient way to iterate over elements in a collection, such as an array or list. Python, however, does not have a dedicated foreach loop like some other languages (e.g., PHP or JavaScript).
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ python_lists_loop.asp
Python - Loop Lists
Python Examples Python Compiler Python Exercises Python Quiz Python Challenges Python Server Python Syllabus Python Study Plan Python Interview Q&A Python Bootcamp Python Certificate Python Training ... Learn more about for loops in our Python For Loops Chapter.
๐ŸŒ
LearnPython.com
learnpython.com โ€บ blog โ€บ python-list-loop
7 Ways to Loop Through a List in Python | LearnPython.com
In other words, the loop has called the print() function four times, each time printing the current item in the list โ€“ i.e. the name of a fruit. List comprehension is similar to the for loop; however, it allows us to create a list and iterate through it in a single line. Due to its utter simplicity, this method is considered one of the most robust ways of iterating over Python lists.
๐ŸŒ
Learnsic
learnsic.com โ€บ blog โ€บ python-foreach-how-to-program-in-python
Python Foreach: How to Program in Python
March 29, 2024 - This website uses cookies to ensure you get the best experience & by continuing to use our website, you agree to our Privacy and Cookie Policy ยท Got it
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ why does python forces you to use "for" instead of "for each" but lets you use "char" and "character"?
r/learnpython on Reddit: Why does Python forces you to use "For" instead of "For Each" but lets you use "char" and "character"?
December 12, 2024 -

Idk I'm new to coding so I might be totally wrong.

It seems to me that "for" means the same thing as "for each". However, it doesn't let me use the longer form.

However, it lets me use the longer form "character" instead of "char"

This is kind of annoying as a new programmer because I want to be able to use the more natural english spelling before going into shortcuts.