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

boB Stepp robertvstepp at gmail.com
Thu May 24 22:21:47 EDT 2018


On Thu, May 24, 2018 at 9: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')

"break" (and "continue") are only meaningful inside for or while
loops.  You do not have one of these inside your function.  See
https://docs.python.org/3/reference/simple_stmts.html#break

-- 
boB



More information about the Python-list mailing list