On Sat, Oct 8, 2011 at 12:34 PM, Andreas Perstinger <
[email protected]> wrote:
> On 2011-10-08 11:11, Andreas Perstinger wrote:
>
>> def swap(sentence):
>> s = sentence.split()
>> for i in reversed(range(len(s))):
>> if s[i].endswith("/N") and s[i-1].endswith("/ADJ"):
>> s[i], s[i-1] = s[i-1], s[i]
>> return s
>>
>
> Oops, noticed a little bug:
>
> The for-loop should be "for i in reversed(range(1, len(s))):" so that
> sentences starting with a noun get processed correctly:
>
> >>> swap("Joe/N went/VBZ crazy/ADJ")
> ['Joe/N', 'went/VBZ', 'crazy/ADJ']
>
> Thanks again Andreas
> Bye, Andreas
> ______________________________**_________________
> Tutor maillist - [email protected]
> To unsubscribe or change subscription options:
> http://mail.python.org/**mailman/listinfo/tutor<http://mail.python.org/mailman/listinfo/tutor>
>
--
لا أعرف مظلوما تواطأ الناس علي هضمه ولا زهدوا في إنصافه كالحقيقة.....محمد
الغزالي
"No victim has ever been more repressed and alienated than the truth"
Emad Soliman Nawfal
Indiana University, Bloomington
--------------------------------------------------------
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor