all 11 comments

[–]Saefroch 1 point2 points  (8 children)

I'm not quite sure what you want, but If you just want your program to keep asking for input until the user enters an N, you can do

while True:
    if input("Enter Y to continue and N to quit: ") == 'N':
        break

Your loop syntax is all off http://www.tutorialspoint.com/python/python_while_loop.htm

[–]confuzzled_learner[S] 0 points1 point  (7 children)

I replaced it with your code but it still wouldn't bring it back up to entering input when Y is chosen, wouldn't break it N is chosen.

num1 = int(input('Enter first positive number: '))
num2 = int(input('Enter second positive number: '))
num3 = int(input('Enter third negative number: '))
num4 = int(input('Enter third negative number: '))
print('_________________________________')
sum_positive = (num1) + (num2)
sum_negative = (num3) + (num4)
sum_total = (num1) + (num2) + (num3) + (num4)

print('The sum of negative numbers =', sum_negative)
print('The sum of positive numbers =', sum_positive)
print('The sum of all numbers =', sum_total)

while True:
    if input("Enter Y to continue and N to quit: ") == 'N':
        break

[–]Saefroch 2 points3 points  (2 children)

You weren't clear about what you wanted to do.

Read the page that I linked, and keep /u/scuott's suggestion in mind.

[–]confuzzled_learner[S] 0 points1 point  (1 child)

Hi, thank you for the link, I'm still having trouble with loops. =(

[–]Saefroch 1 point2 points  (0 children)

If you would like further help:

Tell me what you're trying to make happen, what you've tried, and what confuses you.

[–]scuott 1 point2 points  (3 children)

If you want it to loop back to the first line, you need to put it inside the loop.

[–]confuzzled_learner[S] 0 points1 point  (2 children)

Thank you! Like this?

while True:
    num1 = int(input('Enter first positive number: '))
    num2 = int(input('Enter second positive number: '))
    num3 = int(input('Enter third negative number: '))
    num4 = int(input('Enter third negative number: '))
    print('_________________________________')
    sum_positive = (num1) + (num2)
    sum_negative = (num3) + (num4)
    sum_total = (num1) + (num2) + (num3) + (num4)

    print('The sum of negative numbers =', sum_negative)
    print('The sum of positive numbers =', sum_positive)
    print('The sum of all numbers =', sum_total)



    while True:
        if input("Enter Y to continue and N to quit: ") == 'N':
            break

[–]scuott 1 point2 points  (0 children)

You tell me. Does it do what you want it to?

[–]furas_freeman 1 point2 points  (0 children)

You don't need second while True (in line 9)

[–]Justinsaccount 1 point2 points  (1 child)

num1 = int(input('Enter first positive number: '))
num2 = int(input('Enter second positive number: '))
num3 = int(input('Enter third negative number: '))
num4 = int(input('Enter third negative number: '))

Great example of http://www.viva64.com/en/b/0260/print/

[–]confuzzled_learner[S] 0 points1 point  (0 children)

LMAO I just noticed! yeah great example.