35 lines
773 B
Markdown
35 lines
773 B
Markdown
---
|
|
id: practical-python-1.21
|
|
source_exercise_id: "1.21"
|
|
title: "Membership tests"
|
|
section: "1.5 Lists"
|
|
source_path: "01_Introduction/05_Lists.md"
|
|
source_repo: "https://github.com/dabeaz-course/practical-python"
|
|
source_commit: "93dca856b41c61a0a0f85ae334116e4c125629ea"
|
|
student_visible_solution: false
|
|
has_private_solution: false
|
|
skip: false
|
|
---
|
|
|
|
# Exercise 1.21: Membership tests
|
|
|
|
> Source: Practical Python Programming, `01_Introduction/05_Lists.md`.
|
|
|
|
### Exercise 1.21: Membership tests
|
|
|
|
Use the `in` or `not in` operator to check if `'AIG'`,`'AA'`, and `'CAT'` are in the list of symbols.
|
|
|
|
```python
|
|
>>> # Is 'AIG' IN the `symlist`?
|
|
True
|
|
>>> # Is 'AA' IN the `symlist`?
|
|
False
|
|
>>> # Is 'CAT' NOT IN the `symlist`?
|
|
True
|
|
>>>
|
|
```
|
|
|
|
## 关联来源
|
|
|
|
- [[summaries/05_Lists]]
|