I'm having issues with a phone-number database.
Here is a code snippet:
def menu():
print '''Please make a selection from the following options:
To add an Employee - enter: 1
For a complete listing of Employees - enter: 2
To see the 'test page' and exit the database - enter: 3'''
print
return input(":")
#Start of Program
foo = phonedb()
loop = 1
choice = 0
while loop == 1:
choice = menu()
if choice == 1:
print "Enter the Employee's full name: "
n = raw_input(':')
print "Enter the Employee's full telephone number: "
p = raw_input(':')
print "Enter the telephone number type:(0 = UNKNOWN, 1 = HOME, 2 =
WORK, 3 = FAX, 4 = CELL)"
t = raw_input(':')
if t == '0':
foo.add(n, p, UNKNOWN)
if t == '1':
foo.add(n, p, HOME)
if t == '2':
foo.add(n, p, WORK)
if t == '3':
foo.add(n, p, FAX)
if t == '4':
foo.add(n, p, CELL)
print t
elif choice == 2:
print(list)
loop = 0
It works until I enter "t", then this is what I get:
"Please make a selection from the following options:
To add an Employee - enter: 1
For a complete listing of Employees - enter: 2
To see the 'test page' and exit the database - enter: 3"
:1
Enter the Employee's full name:
:john
Enter the Employee's full telephone number:
:123-456-7890
Enter the telephone number type:(0 = UNKNOWN, 1 = HOME, 2 = WORK, 3 = FAX, 4 =
CELL)
:1
First lookup:
Traceback (most recent call last):
File "F:\CSC113 Module 4 CA\sample database.py", line 72, in <module>
class phonedb:
File "F:\CSC113 Module 4 CA\sample database.py", line 146, in phonedb
for entry in foo.lookup('reifsch'):
File "F:\CSC113 Module 4 CA\sample database.py", line 101, in lookup
if cmp(e, string) == 0:
TypeError: comparison did not return an int
>>>
I do not know what this error means. I tried to look it up in help, but to no
avail. If someone could please help or tell me where I could find an answer.
Thanks.
--
http://mail.python.org/mailman/listinfo/python-list