Problem
Terry Reedy
tjreedy at udel.edu
Tue Mar 28 17:08:20 EST 2000
[posted and emailed]
"InCoGniTo" <josephb at zip.com.au> wrote in message
news:8bn3gj$7qh$1 at the-fly.zip.com.au...
> I'm trying to write a program which does basic bank functions and I have
a
> problem that I can not get it to read my list to see if there is a match
in
> a name so that the prgram can identify whos account it is. Can someone
> please try and help me.
Let's start with some improvements for your code.
def login():
# delete multiple print statements and instead print 1 multiline
string
print '''\
Welcome to Account System.
You now have to login the user to access the account.
'''
# use raw_input(prompt) for data
# note: str(sys.stdin.readline()) is redundant since readline() returns
string
fn = raw_input( 'Please enter the customers First name')
ln = raw_input('Please enter the customers Last name')
for item in customer_list:
if item.firstname == fn and item.lastname == ln:
current_person = item
print 'You have succesfully Logged in, now transfering to
account systems menu\n
# note that you do not need separate print statement for
extra \n
time.sleep(3)
accountmenu()
break # I added this - once match is found, stop looping
# if current_person == None: # broken since indented to
execute within loop
# instead of after and since current_person not
initialized. Replace this with below
else:
print 'Sorry account records are not present in system records'
print 'Going back to level 1'
print 'Loading, please wait ...'
time.sleep(2)
print '\n'
welcome_verfication()
# this sort of construction -- break loop on match, else do non-match
action
# is precisely what else-after-for is meant for.
> There are many other fucntions and classes, for instance customer_list is
my
> list:). I don't get any errors the program just stops and qoutes me the
> module.
Does replacement of broken mismatch test fix problem?
If not, what is last statement executed?
If necessary, add print statements to determine this.
'quotes me the module': what does this mean?
Terry J. Reedy
More information about the Python-list
mailing list