# Python 循环1

使用 for 遍历打印列表信息

```python
# -*- coding: UTF-8 -*-
if __name__ == '__main__':
    list = [
        {
            "id": 966024429,
            "number": 2341,
            "title": "Question about license.",
            "body": "I would like to create a [winget](https://github.com/microsoft/winget-cli) package for jq. 🙏🏻"
        },
        {

            "id": 962477084,
            "number": 2340,
            "title": "visibility of wiki pages",
            "body": "The visibility of wiki pages to search engines is generally limited; for example, the search result for \"jq Cookbook\" looks like this:"
        }
    ]

    # TODO(You): 请在此实现遍历打印代码
```

请选出实现**不正确**的代码。

## template

```python
def test(list):
    i = 0
    for item in list:
        print('')
        print("## 第{}条信息".format(i))
        print("* id: {}".format(item['id']))
        print("* number: {}".format(item['number']))
        print("* title: {}".format(item['title']))
        print("* body: {}".format(item['body']))
        i += 1


if __name__ == '__main__':
    list = [
        {
            "id": 966024429,
            "number": 2341,
            "title": "Question about license.",
            "body": "I would like to create a [winget](https://github.com/microsoft/winget-cli) package for jq. 🙏🏻"
        },
        {

            "id": 962477084,
            "number": 2340,
            "title": "visibility of wiki pages",
            "body": "The visibility of wiki pages to search engines is generally limited; for example, the search result for \"jq Cookbook\" looks like this:"
        }
    ]
    test(list)
```

## 答案

```python
for i, item in list:
    print('')
    print("## 第{}条信息".format(i))
    print("* id: {}".format(item['id']))
    print("* number: {}".format(item['number']))
    print("* title: {}".format(item['title']))
    print("* body: {}".format(item['body']))
```

## 选项

### A

```python
i = 0
for item in list:
    print('')
    print("## 第{}条信息".format(i))
    print("* id: {}".format(item['id']))
    print("* number: {}".format(item['number']))
    print("* title: {}".format(item['title']))
    print("* body: {}".format(item['body']))
    i += 1
```

### B

```python
for i, item in enumerate(list):
    print('')
    print("## 第{}条信息".format(i))
    print("* id: {}".format(item['id']))
    print("* number: {}".format(item['number']))
    print("* title: {}".format(item['title']))
    print("* body: {}".format(item['body']))
```

### C

```python
for i in range(len(list)):
    item = list[i]
    print('')
    print("## 第{}条信息".format(i))
    print("* id: {}".format(item['id']))
    print("* number: {}".format(item['number']))
    print("* title: {}".format(item['title']))
    print("* body: {}".format(item['body']))
```
