I produced the following code to loop keys through a dictionary
favourite_languages = {
'jen':'python',
'sarah':'c',
'edward':'ruby',
'phil':'python'
}
friends = ['sarah', 'phil']
for name in favourite_languages.keys():
print(name.title())
if name in friends:
print(" Hi " + name.title() + ", I see your favourite language is " +
favourite_languages[name].title() + "!")
The output produced is
Jen
Sarah
Edward
Phil
Hi Phil, I see your favourite language is Python!
I however, was expecting the following:
Jen
Sarah
Hi Sarah, I see your favourite language is C!
Edward
Phil
Hi Phil, I see your favourite language is Python!
Why does Sarah not come up in the output?