Re: why do I get syntax error on if : break

2018-05-26 Thread Grant Edwards
On 2018-05-25, asa32s...@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 exi

Re: why do I get syntax error on if : break

2018-05-25 Thread Dan Stromberg
On Thu, May 24, 2018 at 7:12 PM, 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

Re: why do I get syntax error on if : break

2018-05-25 Thread bartc
On 25/05/2018 11:08, asa32s...@gmail.com wrote: On Thursday, May 24, 2018 at 10:12:46 PM UTC-4, asa3...@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') thanks...

Re: why do I get syntax error on if : break

2018-05-25 Thread asa32sd23
On Thursday, May 24, 2018 at 10:12:46 PM UTC-4, asa3...@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') thanks... I believe the compiler. So how do I

Re: why do I get syntax error on if : break

2018-05-24 Thread Steven D'Aprano
On Thu, 24 May 2018 19:12:33 -0700, asa32sd23 wrote: > here is the code, i keep getting an error, "break outside loop". if it > is false just exit function break doesn't exit the function, it exits the loop. There is no loop to exit, so it is an error. Believe the compiler when it tells you the

Re: why do I get syntax error on if : break

2018-05-24 Thread boB Stepp
On Thu, May 24, 2018 at 9:12 PM, 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

why do I get syntax error on if : break

2018-05-24 Thread asa32sd23
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') -- https://mail.python.org/mailman/listinfo/python-list