-2

Since you are not liking my explanation of my program I have changed it purely to only a question now: how do I allow the program to continue to check what the input was and apply a rule according until the output is mu

x = input("Enter your string: ")
while not set(x).issubset({'m', 'u', 'i'}):
    print("false")
    x = input("Enter your string")
    print("Your String is " + x)
if x == ("mu"):
    print("game complete")
    quit()
   #I understand that right now I am only checking if x is mu and then
#displaying the question input
#not sure how to bring the rules into the loop too
else:
    while x !=("mu"):
        Question = int(input("Which rule would you like to apply? enter numbers 1-4: ")
if Question is 1:
    x = (x + "l")
    print(x)
elif Question is 2:
    print("2")
elif Question is 3:
    print("3")
elif Question is 4:
    print("4")
elif Question is not 1 or 2 or 3 or 4:
    print("invalid rule try again")
Timothy Kardaras
  • 123
  • 1
  • 1
  • 8
  • 1
    I have no clue what you are asking. Please try to write your question in short clear sentences rather than an endless obscure blurb. – Julien Apr 21 '16 at 06:17
  • My question is how do I allow the program to continue to check what the input was and apply a rule according until the output is mu, just thought people would want to understand the program – Timothy Kardaras Apr 21 '16 at 07:34

1 Answers1

2

You bring the rules into the while-loop by indenting them accordingly:

while x != "mu":
    Question = int(input("Which rule would you like to apply? enter numbers 1-4: ")
    if Question == 1:
        x = (x + "l")
        print(x)
    elif Question == 2:
        print("2")
    elif Question == 3:
        print("3")
    elif Question == 4:
        print("4")
    else:
        print("invalid rule try again")

By the way: don't us is to compare numbers. Your last elif-condition is wrong, should be Question not in (1, 2, 3, 4) or even better a simple else.

Daniel
  • 42,087
  • 4
  • 55
  • 81