"Danny Laya" <[EMAIL PROTECTED]> wrote

Hi I am making an addressBook program now,
and you know some problem, the program doesn't
work.

Always describe the error and, if possible, send the
error text. Python error messages may seem cryptic to
a beginner but they are actually very informative once
you get used to them!

But I'll take a guess...

def readBook(book)
  import os
  if os.path.exists(filename):
  store = open(filename,'r')

The lines under the if statement should be indented.
It may just be email messing things up but since the
rest were OK I'm guessing that this is the error.
Like this:

def readBook(book):
   import os
   if os.path.exists(filename):
      store = open(filename,'r')
      for line in store:
         name = line.rstrip()
         entry = store.next().rstrip()
         book[name] = entry
      store.close()


Remember that indentation(spacing) is all important
in Python, its how python knows how much or how
little to do as a result of the if test or inside the for loop.

HTH,

--
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld

--------------------------------------------------------------------------------



_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to