From dea0c9d0752cc6e8d0aa2899aa1dd1fae3c07e64 Mon Sep 17 00:00:00 2001 From: cheeks <134818917+leftovertoast@users.noreply.github.com> Date: Mon, 27 Jan 2025 14:27:07 -0500 Subject: [PATCH] 6-06_polling.py --- Chapter_06/6-06_polling.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Chapter_06/6-06_polling.py diff --git a/Chapter_06/6-06_polling.py b/Chapter_06/6-06_polling.py new file mode 100644 index 0000000..054c89b --- /dev/null +++ b/Chapter_06/6-06_polling.py @@ -0,0 +1,22 @@ +# Exercise 6-6 Polling +# Learning Objective: Use an if statement on a loop through a list. + +# favorite_languages.py +favorite_languages = { + 'jen': 'python', + 'sarah': 'c', + 'edward': 'rust', + 'phil': 'python', + } + +poll_takers = ['john', 'stacey', 'edward', 'phil', 'steve'] + +for name in set(poll_takers): + if name in set(favorite_languages.keys()): + print(f"Thank you {name}, for taking part in our poll.") + elif name not in favorite_languages.keys(): + print(f"Hi there {name}, you should take part in our poll") + else: + print("We don't have a record for you, please contact an admin!") + +