From aa31f4cc7470896d5b9e1a4d9918a3f468a979ce Mon Sep 17 00:00:00 2001 From: Rob-Rychs Date: Sun, 15 Apr 2018 10:10:41 -0700 Subject: [PATCH] fix #results in examples, added test file for keys_only --- snippets/all_unique.md | 5 +++-- snippets/has_duplicates.md | 5 +++-- snippets/keys_only.md | 3 +-- snippets/values_only.md | 3 +-- test/keys_only/keys_only.py | 5 +++++ 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/snippets/all_unique.md b/snippets/all_unique.md index 020e65f2e..ea4177beb 100644 --- a/snippets/all_unique.md +++ b/snippets/all_unique.md @@ -11,6 +11,7 @@ def all_unique(lst): ``` python x = [1,2,3,4,5,6] -all_unique(x) # result -True +y = [1,2,2,3,4,5] +all_unique(x) # True +all_unique(y) # False ``` \ No newline at end of file diff --git a/snippets/has_duplicates.md b/snippets/has_duplicates.md index 2c0f65f5e..3a7535919 100644 --- a/snippets/has_duplicates.md +++ b/snippets/has_duplicates.md @@ -11,6 +11,7 @@ def has_duplicates(lst): ``` python x = [1,2,3,4,5,5] -has_duplicates(x) # result -True +y = [1,2,3,4,5] +has_duplicates(x) # True +has_duplicates(y) # False ``` diff --git a/snippets/keys_only.md b/snippets/keys_only.md index 7c2a3e478..1dc5a4d0d 100644 --- a/snippets/keys_only.md +++ b/snippets/keys_only.md @@ -18,6 +18,5 @@ ages = { "Isabel": 11, "Anna": 9, } -keys_only(ages) # result -['Peter', 'Isabel', 'Anna'] +keys_only(ages) # ['Peter', 'Isabel', 'Anna'] ``` \ No newline at end of file diff --git a/snippets/values_only.md b/snippets/values_only.md index e326dd9a9..ddda0731d 100644 --- a/snippets/values_only.md +++ b/snippets/values_only.md @@ -18,6 +18,5 @@ ages = { "Isabel": 11, "Anna": 9, } -values_only(ages) # result -[10, 11, 9] +values_only(ages) # [10, 11, 9] ``` \ No newline at end of file diff --git a/test/keys_only/keys_only.py b/test/keys_only/keys_only.py index e69de29bb..5f97a2265 100644 --- a/test/keys_only/keys_only.py +++ b/test/keys_only/keys_only.py @@ -0,0 +1,5 @@ +def keys_only(dict): + lst = [] + for k, v in dict.items(): + lst.append(k) + return lst \ No newline at end of file