Synax error in string assignment

Chris Angelico rosuav at gmail.com
Sun Aug 19 01:04:49 EDT 2018


On Sun, Aug 19, 2018 at 2:47 PM, Sharan Basappa
<sharan.basappa at gmail.com> wrote:
> I am not sure what the issue is with the 2nd file that assigns string to text variable.
>
> Here is the code:
> # -*- coding: utf-8 -*-
> text = “this’s a sent tokenize test. this is sent two. is this sent three? sent 4 is cool! Now it’s your turn.”
> from nltk.tokenize import sent_tokenize
> sent_tokenize_list = sent_tokenize(text)
> len(sent_tokenize_list)
> sent_tokenize_list
>
> Here is the error:
>  text = “this’s a sent tokenize test. this is sent two. is this sent three? sent 4 is cool! Now it’s your turn.”
>            ^
> SyntaxError: invalid syntax
>
> BTW, the ^ operator pointing to the error is at text = and not for cool word. This is due to formatting issue in google group.

Is that a curly quote character in your source code, or did it get
changed as part of posting to this list? Either way, you need to be
careful with your quote characters. Get a programmer's editor if you
need to (Sublime, Atom, VS Code, Vim, SciTE, etc, etc, etc), and make
sure you post as plain text.

(Also, if you have trouble posting properly using Google Groups,
switch to the mailing list - it's more reliable.)

ChrisA



More information about the Python-list mailing list