Hi,<br><br>I have the following dictionary:<br><br>pairs = {"Jon Moore": ["Tony Moore", "Stanley Moore"],<br> "Simon Nightingale": ["John Nightingale", "Alan Nightingale"],
<br> "David Willett": ["Bernard Willet", "Robert Willet"],<br> "John Jackson": ["John Jackson", "Peter Jackson"],<br> "James Southey": ["Richard Southey", "Paul Southey"],
<br> "Shaun Forsythe": ["William Forsythe", "Angus Forsythe"],<br> "Daniel Geach": ["Mike Geach", "Andy Geach"]}<br><br>Where the names represent a son, father and grandfather.
<br><br>I am trying to add a new term and related definitions to the dictionary, but my code does not seem to work:<br><br> son = raw_input("Please enter the name of the Son: ")<br> if son not in pairs:
<br> father = raw_input("Who is the Father?: ")<br> grandfather = raw_input("What is the Grand Father?: ")<br> pairs[son][0] = father<br> pairs[son][1] = grandfather
<br> print "\n", son, ",", father, "and" ,grandfather, "have been added."<br> else:<br> print "\nThat Son already exists!"<br><br>The error I get is:
<br><br clear="all">Please enter the name of the Son: Steven Bates<br>Who is the Father?: Alan Bates<br>What is the Grand Father?: Master Bates<br>Traceback (most recent call last):<br> File "C:\Documents and Settings\Administrator\Desktop\FOO\transfer\whos_your_daddy_and_grandaddy.py", line 65, in ?
<br> pairs[son][0] = father<br>KeyError: 'Steven Bates'<br>>>> <br><br>Where am I going wrong?<br>-- <br>Best Regards<br><br>Jon Moore