From 7d1de5f948bc76894c34c9b0dbe994a6fb8b9a98 Mon Sep 17 00:00:00 2001 From: David Rotermund <54365609+davrot@users.noreply.github.com> Date: Mon, 11 Dec 2023 17:52:25 +0100 Subject: [PATCH] Update README.md Signed-off-by: David Rotermund <54365609+davrot@users.noreply.github.com> --- python_basics/list/README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/python_basics/list/README.md b/python_basics/list/README.md index 2ff323e..43bfe66 100644 --- a/python_basics/list/README.md +++ b/python_basics/list/README.md @@ -210,6 +210,25 @@ del collection_of_strings[1] print(collection_of_strings) # -> ['AA', 'CC', 'DD'] ``` +## in + +```python +collection_of_strings = [ + "AA", + "BB", + "CC", + "DD", + "EE", + "FF", + "GG", + "HH", +] +print("AA" in collection_of_strings) # -> True +print("XX" in collection_of_strings) # -> False +print("AA" not in collection_of_strings) # -> False +print("XX" not in collection_of_strings) # -> True +``` + ## [Additional commands](https://docs.python.org/3/tutorial/datastructures.html) ||