Last active
August 29, 2015 14:18
-
-
Save marythought/5078f2acb20dcaa5f24c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this is the file for donorletters code | |
d = {"mary": 50, "josh": 50, "cassie": 34} | |
print d | |
d["mary"] = 100 | |
print d | |
# ok, this method overwrites the existing donation amt. how can I add an amt? | |
d["mary"] = (d["mary"], 50) | |
print d | |
print d.keys() | |
print d["mary"] | |
print d["mary"][0] | |
print d["mary"][1] | |
# now I can add an amt & create a tuple that I can then call via place number. | |
# let's make this a function | |
def addamt(name, dict, amt): | |
for key, value in dict.items(): | |
if key == name: | |
dict[key] = (value, amt) | |
elif name not in dict.keys(): | |
dict[name] = amt | |
return dict | |
addamt("mary", d, 45) | |
addamt("OC", d, 1000) | |
addamt("josh", d, 56) | |
print d | |
print d["mary"][0] | |
print d["mary"][1] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment