From 95e94c3353537d7ae83daabdcfd01194cbfd202c Mon Sep 17 00:00:00 2001 From: David Rotermund <54365609+davrot@users.noreply.github.com> Date: Wed, 6 Dec 2023 23:36:11 +0100 Subject: [PATCH] Update README.md Signed-off-by: David Rotermund <54365609+davrot@users.noreply.github.com> --- python_basics/if/README.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/python_basics/if/README.md b/python_basics/if/README.md index fdae6a0..9088072 100644 --- a/python_basics/if/README.md +++ b/python_basics/if/README.md @@ -35,3 +35,32 @@ if_stmt ::= "if" assignment_expression ":" suite ["else" ":" suite] ``` +## if, elif, else with lists + +```python +A = 1​ +if A in [0, 2, 4, 6, 8]:​ + print("found")​ +else:​ + print("NOT found")​ +``` + +Output + +```python +NOT found +``` + +```python +A = 2 +if A in [0, 2, 4, 6, 8]:​ + print("found")​ +else:​ + print("NOT found")​ +``` + +Output + +```python +found +```