-1

I want to allow the user to construct an argument using premises (sentences that support your argument) and a conclusion. I want the program to raise a question (yes/no) if the user wants to add an additional premises after the first one. If yes --> premises: ____, If no --> Conclusion: ____. The problem is that i can write no for the additional premises question (or anything) and it'd take that input and make another premises.

Thank you in advance for any help!

print("Welcome to the argument-validity test!")       

def premises_conclusion():

    premises_1 = raw_input("Premises: ")
    premises_qstn = raw_input("Would you like an additional premises(yes/no)? ")
    additional_premises = raw_input("Premises: ")

    while premises_qstn.isalpha():

        additional_premises = raw_input("Premises: ")

        if premises_qstn == 'yes':
            additional_premises = raw_input("Premises: ")

        elif premises_qstn == "no":
            break

        else:
            print("Please enter yes or no.")

    conclusion = input("Conclusion: ")

premises_conclusion()




# When i use additional_premises in line 7, the while statement asks the additional
# premises even if i say 'no'.

# When i delete additional_premises in line 7, the while statement only skips
# to the conclusion (acts like i said no for yes). No matter what I say it
# skips to the conclusion.
Manolo Ribera
  • 103
  • 1
  • 4
  • 8
  • If the reason for your loop is to repeatedly query the user till they give a valid response, take a look at this SO q&a, [Asking the user for input until they give a valid response](http://stackoverflow.com/questions/23294658/asking-the-user-for-input-until-they-give-a-valid-response). You should remove everything from the loop except for validating the user's response. – wwii Sep 25 '16 at 23:05

1 Answers1

1

These lines seem problematic:

premises_qstn = raw_input("Would you like an additional premises(yes/no)? ")
additional_premises = raw_input("Premises: ")

It asks if you want additional premises, but doesn't check the input (premises_qstn) before immediately asking for more no matter what.

Then, the first line inside the while loop asks for premises again, but the loop breaking condition of elif premises_qstn == "no": still hasn't been checked.

audiodude
  • 1,865
  • 16
  • 22