From db9c09f4ba39b7f859ccbddbce647de5f8cd1ee5 Mon Sep 17 00:00:00 2001 From: NilsForssen Date: Mon, 7 Feb 2022 09:18:48 +0100 Subject: [PATCH] pc --- laboration3/uppgift_1.py | 17 +++++++++-------- uppgift_1.txt | 21 +++++++++++++++++++++ 2 files changed, 30 insertions(+), 8 deletions(-) create mode 100644 uppgift_1.txt diff --git a/laboration3/uppgift_1.py b/laboration3/uppgift_1.py index 345b740..0c0b920 100644 --- a/laboration3/uppgift_1.py +++ b/laboration3/uppgift_1.py @@ -21,8 +21,8 @@ def increment_dictionary_value1(key, d): d[key] += 1 -def increment_dictionary_value2(key, value, d): - if key not in value: +def increment_dictionary_value2(key, d): + if key not in d: d[key] = 1 else: d[key] += 1 @@ -41,9 +41,10 @@ def return_value_list1(prefix, d): def value_exists2(value, d): - for d in d.values: - if "__contains__" in dir(d): - if value in d: - return True - else: - return False + for v in d.values(): + if v == value: + return True + elif isinstance(v, list) and value in v: + return True + + return False \ No newline at end of file diff --git a/uppgift_1.txt b/uppgift_1.txt new file mode 100644 index 0000000..0f75ecc --- /dev/null +++ b/uppgift_1.txt @@ -0,0 +1,21 @@ +UEsDBBQAAAAIAEdKR1REFzSfLgEAAFYDAAAaABwAbmlsZm8zNTktcHl1cHBnM18xL29yaWcucHlV +VAkAA8bVAGLG1QBidXgLAAEEehxpWQQA4fUFhVJNb4MwDL3zKyztAlpViR4rcd0v2E6oQhExU9TU +oCSl5d/P+eiAdms5BdvvPfvZb/A1DN+qc1BmmcQOjjg1eFXW2ZyfG5DFPgP+DLqzIZ8GRSCzWD0K +fcZUX+bh7wESogG0DU+bFwktpGxc30jVuih2RyBrjh6givEFiPDS9KSnp2gVhgHqXRCPwX9pFbUG +T0guEKqehJmaUFCujUjo98o79gK6W0Nfd1SGEGqLD8mFYPItmq/Z+/KJfVsxDEgyLufmfFzNimEw +2KnrjHbcZQX1Ifx0vYEjC8Q1Kocn3uLcoh+s3mukxFLwLBXE91yVWH8bKpZXwok/bmp3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