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

Grant Edwards grant.b.edwards at gmail.com
Sat May 26 09:30:24 EDT 2018


On 2018-05-25, asa32sd23 at gmail.com <asa32sd23 at gmail.com> wrote:

> here is the code, i keep getting an error, "break outside loop".

You get the "break outside loop" error because you're using the break
statement when you are not inside a loop.

> if it is false just exit function

You use the 'return' statement to exit a function.

> def d(idx):
>     if type(idx) != int:
>         break
>
> d('k')





More information about the Python-list mailing list