# Python 三元表达式(1)

Python 没有问号表达式了！使用三元组表达式统计偶数个数

```python
# -*- coding: UTF-8 -*-
if __name__ == '__main__':
    pi = [3, 14, 15, 9, 26, 5, 35, 8, 97, 932]
    even_count = 0
    for i in pi:
        # TODO(you): 请在此实现统计代码
    assert even_count == 4
```

请选出下列能**正确**实现这一功能的选项。

## template

```python
if __name__ == '__main__':
    pi = [3, 14, 15, 9, 26, 5, 35, 8, 97, 932]
    even_count = 0
    for i in pi:
        even_count += 1 if i % 2 == 0 else 0
    assert even_count == 4
```

## 答案

```python
even_count += 1 if i % 2 == 0 else 0
```

## 选项

### A

```python
even_count += if i % 2 == 0: 1 else 0
```

### B

```python
even_count += 0 if i % 2 == 0 else 1
```

### C

```python
even_count += 1 if i % 2 != 0 else 0
```
