6-06_polling.py
This commit is contained in:
parent
110efb5eea
commit
dea0c9d075
22
Chapter_06/6-06_polling.py
Normal file
22
Chapter_06/6-06_polling.py
Normal file
@ -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!")
|
||||||
|
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user