2025-01-27 14:27:07 -05:00

23 lines
610 B
Python

# 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!")