[Tutor] Urgent question about program debugging
Charles Bartley
blackspeckpotato at frontiernet.net
Thu Apr 6 04:43:09 CEST 2006
Hi Ros,
I placed two new lines of code in your choices 2 and 7. The new lines have comments trailing them.
In choice 7, you forgot to delete the previous father_son pair (as you had done in choice 5).
Regards,
Charles
#######
# list all fathers
elif choice == "2":
print "LIST OF ALL FATHERS\n"
print father_son.keys() # print fathers - their the keys
# replace a father-son pair
elif choice == "7":
term = raw_input("Type in the name of the father which corresponds \
to the father-son pair you want to replace: ")
if term in father_son:
del father_son[term] # delete previous father_son pair
term = raw_input("Type in name of this 'replacement' father: ")
definition = raw_input("Type in the name of this person's son: ")
father_son[term] = definition
print "A new father-son pair has been added.", term, "is the \
father of", definition
else:
print "\nSorry, but", choice, "isn't a valid choice."
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20060405/74a25874/attachment.htm
More information about the Tutor
mailing list