Exercise 1.15

28 views
Skip to first unread message

Jason

unread,
Sep 21, 2016, 6:39:46 AM9/21/16
to nltk-users
Confused about Exercise 1.15.

I used x.startswith(b) and finally got the list comprehension to work, but why didn't it work before when I first used:

sorted(x for x in set(text5) if x[0] == 'b')

 I received the error "IndexError: string index out of range"

I played around and x[0] returns a value, so does x[0][0].

Am I missing something?






Fred Mailhot

unread,
Sep 21, 2016, 10:11:12 AM9/21/16
to nltk-...@googlegroups.com
There's an item in text5 with zero length.

--
You received this message because you are subscribed to the Google Groups "nltk-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nltk-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages