guessing numbers from 1 to 8
<p>My program needs to guess the user's number (from 1 to 8) by only asking 3 questions. It prints the first two questions correctly but then when I press enter for the third question, it just prints the last input I did.
How to make all inputs (yes or no) lower case? </p>

<pre><code># Simple Expert System
#firstQuestion = prstr(firstQuestion.lower()) 

print("Think of a number between 1 and 8.")

firstQuestion = (raw_input("Is it an even number? "))
secondQuestion = "Is it less than or equal to 4? "
thirdQuestion = "Is it less than or equal to 3? "
fourthQuestion = "Is it less than 3? "
fifthQuestion = "Is it greater than 6? "
sixthQuestion = "Is it greater than 5? "
seventhQuestion = "Is it less than 2? "




if firstQuestion == "yes":
    print(raw_input(secondQuestion))
elif firstQuestion == "no":
    print(raw_input(thirdQuestion))
elif secondQuestion == "yes":
    print(raw_input(fourthQuestion))
elif secondQuestion == "no":
    print(raw_input(fifthQuestion))
elif thirdQuestion == "no":
    print(raw_input(sixthQuestion))
elif thirdQuestion == "yes":
    print(raw_input(seventhQuestion))

elif fourthQuestion == "yes":
    print("Your number is 2")
elif fourthQuestion == "no":
    print("Your number is 4")

elif fifthQuestion == "yes":
    print("Your number is 8")
elif fifthQuestion == "no":
    print("Your number is 6")   

elif sixthQuestion == "yes":
    print("Your number is 7")
elif sixthQuestion == "no":
    print("Your number is 5")       

elif seventhQuestion == "yes":
    print("Your number is 1")
elif seventhQuestion == "no":
    print("Your number is 3")   
</code></pre>

<p>What you've got there doesn't actually use the input from any of the questions except the first. For example:</p>

<pre><code>secondQuestion = "Is it less than or equal to 4? "
# other stuff
elif secondQuestion == "yes": # will never be true
</code></pre>

<p>Calling <code>raw_input(secondQuestion)</code> doesn't change the value of <code>secondQuestion</code>, it just returns the input. Which in your case means printing it a second time.</p>

<p>Also, your <code>elif</code>s mean that it will only check until the first one comes out true - so if you answered <code>'yes'</code> to the first question, it prints and requests input for the second question, and stops there.</p>

<p>Something that would be more like what you want:</p>

<pre><code>questions = []
questions.append("Is it an even number? ")
questions.append("Is it less than or equal to 4? ")
questions.append("Is it less than or equal to 3? ")
questions.append("Is it less than 3? ")
questions.append("Is it greater than 6? ")
questions.append("Is it greater than 5? ")
questions.append("Is it less than 2? ")


answers = [raw_input(q) for q in questions]
# Make sure to validate input
while True:
    if answers[0] == 'yes':
        is_even = True
        break
    elif answers[0] == 'no':
        is_even = False
        break
    else:
        answers[0] = raw_input("Yes or no, please. ")

# Now repeat that pattern with later questions

while True:
    if answers[1] == 'yes':
        maximum = 4
        break
    elif answers[1] == 'no':
        minimum = 5
        break
    else:
        answers[1] = raw_input("Yes or no, please. ")

# Continue collecting data like this for all questions,
# Then use it at the end to get an answer
</code></pre>

<p>There's definitely a more efficient way to do it - no reason to hardcode all the questions, for example, it's just a binary search - but this is closer to what you had written than that.</p>

python python-2.7 python-3.x if-statement