Advertisement
eallik

Untitled

Apr 16th, 2014
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.27 KB | None | 0 0
  1. myDict = {}
  2.  
  3. with open("names.dat") as f:
  4.     myDict = dict(pair.split(":") for pair in line.strip().split(", ") for line in f)
  5.  
  6. for key, val in myDict.items():
  7.     print "father: ", key, " son: ", val
  8.  
  9. lookUp = raw_input("Enter a son's name: ")
  10. print myDict[lookUp]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement