cannot figure out how to end my loop. i see that the last line is within the main FOR loop, so that's why it's printing. do i need to add a while loop? i'm stuck.
n=raw_input ("Enter # to test: ")
n=int(n)
for c in range (0,n):
remainder = n-(20*c)
for b in range (0,n):
a = remainder-(9*b)
a = a/6
if 6*a + 9*b + 20*c == n:
if a>=0 and b>=0 and c>=0:
print n," can be bought",a,b,c
print n," cannot be bought"
if i enter 6, i get:
Enter # to test: 6
6 can be bought 1 0 0
6 cannot be bought
# don't want this last line to print

Hey! We 've verified this expert answer for you, click below to unlock the details :)

I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!

You can use the "break" function to end any for or while loop.

Looking for something else?

Not the answer you are looking for? Search for more explanations.

## More answers

Looking for something else?

Not the answer you are looking for? Search for more explanations.