diff --git a/05_hash_tables/python/01_price_of_groceries.py b/05_hash_tables/python/01_price_of_groceries.py new file mode 100644 index 0000000..6eeddb4 --- /dev/null +++ b/05_hash_tables/python/01_price_of_groceries.py @@ -0,0 +1,7 @@ +book = dict() +# an apple costs 67 cents +book["apple"] = 0.67 +# milk costs $1.49 +book["milk"] = 1.49 +book["avocado"] = 1.49 +print book diff --git a/05_hash_tables/python/02_check_voter.py b/05_hash_tables/python/02_check_voter.py new file mode 100644 index 0000000..0b2cb02 --- /dev/null +++ b/05_hash_tables/python/02_check_voter.py @@ -0,0 +1,11 @@ +voted = {} +def check_voter(name): + if voted.get(name): + print "kick them out!" + else: + voted[name] = True + print "let them vote!" + +check_voter("tom") +check_voter("mike") +check_voter("mike")