why do I get syntax error on if <code>: break

Dan Stromberg drsalists at gmail.com
Fri May 25 19:26:36 EDT 2018


On Thu, May 24, 2018 at 7:12 PM, <asa32sd23 at gmail.com> wrote:

> here is the code, i keep getting an error, "break outside loop". if it is
> false just exit function
>
>
> def d(idx):
>     if type(idx) != int:
>         break
>
> d('k')


Not what you asked, but I believe pylint recommends using not isinstance
instead of type !=.



More information about the Python-list mailing list