---
# System prepended metadata

title: 2022/01/07 python筆記-迭代函數

---

# 2022/01/07 python筆記-迭代函數


```
map()



---

filter()
import math
def is_sqr(x):
    return math.sqrt(x) % 1 == 0
 
newlist = filter(is_sqr, range(1, 101))
print(newlist)
[1, 4, 9, 16, 25, 36, 49, 64, 81, 100]


---

enumerate() 
>>>seq = ['one', 'two', 'three']
>>> for i, element in enumerate(seq):
...     print i, element
... 
0 one
1 two
2 three



---

zip()
```
[map ](https://www.runoob.com/python/python-func-map.html)

[filter](https://www.runoob.com/python/python-func-filter.html) 

[enumerate](https://www.runoob.com/python/python-func-enumerate.html)

[zip](https://www.runoob.com/python/python-func-zip.html)


enumerate + zip 一起使用
```
years = [1995,1996,1997,1998]
name = ['Nico','Harper','Chris','Kisy']

for i,(y,n) in enumerate(zip(years,name)):
  print("{}名字為{},出生於{}".format(i,n,y))
```

