Python Forum
not not working looping through a dictionary
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
not not working looping through a dictionary
#1
peoples = ['jen', 'sarah', 'edward', 'phil', 'jeff', 'cara', 'ben', 'adam', 'larry']
favorite_languages = {
    'jen' : 'python',
    'sarah' : 'c',
    'edward' : 'ruby',
    'phil' : 'python',
    'jeff' : 'python',
    'cara' : 'none',
    }
for people in favorite_languages.keys():
	if people in favorite_languages:
		print("Thanks " + people.title() + " for taking the survey.")
	if people not in favorite_languages:
		print(people + ", Please take the survey.")
Output when run. The not gets overlooked.

Thanks Jen for taking the survey.
Thanks Sarah for taking the survey.
Thanks Edward for taking the survey.
Thanks Phil for taking the survey.
Thanks Jeff for taking the survey.
Thanks Cara for taking the survey.


------------------
(program exited with code: 0)

Press any key to continue . . .
Reply


Messages In This Thread
not not working looping through a dictionary - by rtbr17 - Oct-04-2018, 01:28 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  looping a dictionary harmans14 1 2,176 Apr-11-2021, 08:48 PM
Last Post: bowlofred
  making list in looping a dictionary glennford49 9 3,605 Jun-25-2020, 03:23 PM
Last Post: ndc85430
  Looping through dictionary and comparing values with elements of a separate list. Mr_Keystrokes 5 3,921 Jun-22-2018, 03:08 PM
Last Post: wavic
  Looping issue, stops working JohnOsis 7 4,467 Apr-05-2018, 09:20 PM
Last Post: nilamo
  Changing dictionary values not working SnekLover123 5 4,026 Nov-01-2017, 05:39 PM
Last Post: metulburr

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020