[Tutor] Need help with this source code

christopher lavezza clavezza at hotmail.com
Mon Aug 16 01:06:46 CEST 2004


Can someone please run the source code and give me some help in where I made 
my mistakes in the source code.  Thank you very much.  Source code is at the 
bottom of this email.


Chris


#!c:\python\python.exe

import sys
from phone import *

#Start of Program
b = 1
foo = phonedb()
while b != 3:
    print b
    print "Welcome to the Phone Database!"
    print "---written by Chris Lavezza---"

    print "Please make a selection by typing one of the following options."
    print
    print "If you want to add an Employee type the #: 1"
    print
    print"For a complete listing of Employees type the #: 2"
    print
    print "To see the 'test page' and exit the Database type the #: 3"
    b = input(':')
    if b == 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

    if b == 2:
        print (list)


#  if not being loaded as a module, run a small test
if __name__ == '__main__':
        foo = phonedb()
        foo.add('Sean Reifschneider', '970-555-1111', HOME)
        foo.add('Sean Reifschneider', '970-555-2222', CELL)
        foo.add('Evelyn Mitchell', '970-555-1111', HOME)
        foo.add('Chad Varner','970-123-4567',HOME)

        print 'First lookup:'
        for entry in foo.lookup('reifsch'):
                print '%-40s %s (%s)' % ( entry.name, entry.number, 
entry.showtype() )
        print

        print 'Second lookup:'
        for entry in foo.lookup('e'):
                print '%-40s %s (%s)' % ( entry.name, entry.number, 
entry.showtype() )

_________________________________________________________________
Don’t just search. Find. Check out the new MSN Search! 
http://search.msn.click-url.com/go/onm00200636ave/direct/01/



More information about the Tutor mailing list