[Tutor] Loops
pa yo
payo2000 at gmail.com
Sat Feb 14 23:57:42 CET 2009
Thanks Alan.
after a few hours scratching my head I finally fixed it by removing
all the indents and remaking them in the correct position.
Payo
On Sat, Feb 14, 2009 at 1:52 AM, Alan Gauld <alan.gauld at btinternet.com> wrote:
> "pa yo" <payo2000 at gmail.com> wrote
>
>> The way I have come up with to solve this problem is to put the
>> following loop in:
>>
>>>> rawfeed = feedparser(http//twitter.com/foobar....)
>>>> feedstring = rawfeed.split('=',1) #this splits the feed at the
>>>> first "="
>>>> headline = feedstring[0] #this is the text infront of
>>>> the "=" sign.
>>>> if len(headlinestring) == len(rawfeed) #ie. if the split hasn't
>>>> worked they will be exactly the same >>> body = "\x7b\x7bEmpty\x7d\x7d"
>>>> #this adds an "{{Empty}}" template to the wiki
>>>> else:
>>>> body = feedstring[1]
>
> Sorry, where is the loop?
>
>> But I can't get it to work - I have tried various indents and break
>> and continues - but I don't know enough about loops to identify what I
>> have done wrong.
>
> I'm confused, there is no loop only a conditional statement (if/else)
> The only loops supported in Python are for and while (OK you
> could count list comprehensions/generator expressions too) and
> neither of them are in your code.
>
> However you don't tell us what is happening that you don;t expect.
> Are you getting an error message? If so what (all of it please)?
> Or is it just the output that is different to what you expect?
> if so what did you expect and what did you get?
>
> And finally which version of Python and which OS please?
>
> --
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
More information about the Tutor
mailing list