Jacob S. wrote:
Try writing the code to do what lstrip actually does
- its much harder. So the library includes the more
difficult function and lets you code the easy ones.


def lstrip(string,chars=' ')
   string = list(string)
   t = 0
   for x in string:
       if x in chars:
           string.remove(t)
       else:
           break
       t = t+1


Okay, so it's not that difficult,

Well, after fixing the obvious syntax error I tried print lstrip('abcd', 'abcd')

and got
Traceback (most recent call last):
  File "D:\Personal\Tutor\LStrip.py", line 11, in ?
    print lstrip('abcd', 'abcd')
  File "D:\Personal\Tutor\LStrip.py", line 6, in lstrip
    string.remove(t)
ValueError: list.remove(x): x not in list

so maybe it's not that easy either. Don't forget the unit tests! :-)

Kent

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

Reply via email to