foreach example first class citizen

This commit is contained in:
Mert Gör 🇹🇷 2023-07-02 17:09:30 +03:00
parent b87bcb3b30
commit 26100e1c1e
No known key found for this signature in database
GPG key ID: 2100A876D55B39B9

10
python-temel/foreach.py Normal file
View file

@ -0,0 +1,10 @@
def foreach(l, f):
for x in l:
f(x)
def foo(x):
print('foo: {}'.format(x))
foreach([1, 2, 3, 4, 5], foo)
foreach([1, 2, 3, 4, 5], print)