On Fri, 19 Apr 2019 at 11:19 PM Tamara Berger <brg...@gmail.com> wrote:
> Hi Shaki, > > Thanks for your reply. I tried your code, but it didn't work. Here is the > section of code and your addition: > > if ((monthly_salary*t)*compound_int)<downpayment: > print('It is not possible to save for the downpayment in 36 months.') > break > import sys > sys.exit() > Include the sys.exit() before the break. You cannot have two branching statements in the same block. So it'd be, if ((monthly_salary*t)*compound_int)<downpayment: print('It is not possible to save for the downpayment in 36 months.') import sys sys.exit() > Thanks, > Tamara > > > On Fri, Apr 19, 2019 at 1:23 PM Shakti Kumar < > shakti.shrivastav...@gmail.com> wrote: > >> >> >> On Fri, 19 Apr 2019 at 9:33 PM Tamara Berger <brg...@gmail.com> wrote: >> >>> Hi Python-List, >>> >>> What code can I use to break out of a program completely, and not just >>> out >>> of a loop? >> >> >> import sys >> sys.exit() >> >> Should do your work. >> >>> >> >> I wrote code with 3 conditions for saving for a downpayment. The >>> first addresses cases that don't meet the minimum condition; i.e., enough >>> money to save for a downpayment within the allotted time. It has its own >>> print line, but also executes the irrelevant print lines for the other >>> two >>> conditions. >> >> >> However anyone would suggest to put the prints in the proper if else >> block rather than going for an exit. >> >>> >> >>> -- >>> https://mail.python.org/mailman/listinfo/python-list >> >> >> Thanks, >> Shakti. >> >>> <https://mail.python.org/mailman/listinfo/python-list> >>> >> -- >> Sent from Shakti’s iPhone >> > -- Sent from Shakti’s iPhone -- https://mail.python.org/mailman/listinfo/python-list