[Tutor] RE: Tutor digest, Vol 1 #363 - 6 msgs

Daniel Yoo dyoo@hkn.EECS.Berkeley.EDU
Mon, 17 Jul 2000 20:06:49 -0700 (PDT)

> The way you suggestion is the way I tried it in IDLE but I wasn't sure
> how an empty line would be treated.  Now that I think about it more a
> blank line wouldn't meet the two if's so it would skip the recursion
> and return the empty line.
> Is my thinking correct?

The problem which Issac pointed out before is that the very act of looking
at the first character of the string breaks if the string is empty.  For

  mystring = ""
  print mystring[0]

will cause an IndexError.  This makes sense: it's a string of length zero,
so trying to look at its first element should be an error.  One safe way
to avoid these problems is to check the length of the string using len()
before attempting to work with the string.