On Fri, May 30, 2008 at 7:52 AM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Yes I do need to learn the basics of programming ;) > > This was the first I did, was to put the modification code into the > loop, but had this error: > >>>> for x in otp: > ... price = float(x.contents[1].lstrip(' $')) > ... x.contents[1].replaceWith('$%0.2f' % (price * 0.85)) > ... > Traceback (most recent call last): > File "<stdin>", line 2, in <module> > IndexError: list index out of range
Your <td> cells do not have the same structure, some have no <span>, some have a <span> before the price, the price may be inside a <span> or not...you will have to write your program to deal with this variation. I guess your loop failed on the first <td> that doesn't have a <span>. If you print x in the loop that would help you figure out which one is the problem. Kent _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor