[Tutor] still breaking chains

Jim Mooney cybervigilante at gmail.com
Mon Apr 13 01:44:22 CEST 2015


On Apr 12, 2015 4:00 PM, "Jim Mooney" <cybervigilante at gmail.com> wrote:

> >
> > If join returns a string, why am I getting a syntax error when I try  to
> > slice it?
> >
> > >>> 'alfabeta'[2:5]
> > 'fab'
> > >>> ''.join(['a', 'l', 'f', 'a', 'b', 'e', 't', 'a')[2:5]
> > SyntaxError: invalid syntax
>
> If you're seeing a SyntaxError, don't look for explanations that are
> semantic.  Look for syntax.In this case, note that the list of characters
> had not been closed with a right bracket yet.
>
> Best of wishes!
>

Eeek! How did I miss that? Won't be the first time I confused mistyping
with misunderstanding ;')

-- 
Jim


More information about the Tutor mailing list