From 1e7b25c931e69bac52065e5b547ae073f642c2b9 Mon Sep 17 00:00:00 2001 From: Shisei <120374041+shisei12uni@users.noreply.github.com> Date: Sat, 2 Aug 2025 19:21:39 +0100 Subject: [PATCH] created friend group model --- README.md | 2 +- group.py | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6d7f0c9..1e2bf3d 100644 --- a/README.md +++ b/README.md @@ -25,4 +25,4 @@ Some things you may wish to consider in your model: - Does it allow people who have no job? - Does it allow people with no connections? - Does it assume that connections are always reciprocal (e.g. if A is B's friend, does B -automatically consider A a friend too?) + automatically consider A a friend too?) diff --git a/group.py b/group.py index e2ec347..31fddc1 100644 --- a/group.py +++ b/group.py @@ -2,4 +2,54 @@ # Your code to go here... -my_group = +my_group = { + "Jill": { + "age": 26, + "job": ["biologist"], + "relationships": { + "friend": "Zalika", + "partner": "John" + } + }, + + "Zalika": { + "age": 28, + "job": ["artist"], + "relationships": { + "friend": "Jill", + "landlord": "Nash" + } + }, + + "John": { + "age": 27, + "job": ["writer"], + "relationships": { + "partner": "Jill", + "cousin": "Nash" + } + }, + + "Nash": { + "age": 34, + "job": ["chef"], + "relationships": { + "cousin": "John", + "tenant": "Zalika" + } + }, + + "Nanashi": { + "age": 20, + "job": [], + "relationships": {} + } +} + +# checking if the dictionary correctly reflects relations +for names in my_group.keys(): + if my_group[names]["relationships"]: + for name2 in my_group[names]["relationships"].values(): + print (f"{names} knows {name2}") + else: + print (f"{names} doesn't know anyone in my group.") \ No newline at end of file