0
def func1(a,b):

    c = a * b
    print c
    return c

def func2(a,b):

    c = a * b
    print c
    return c

def func3(a,b):

    c = a * b
    print c
    return c

four = "F"
nine = "N"
sixteen = "S"

print "Enter F,N,or S for your choice."

answer = raw_input("Enter the letter of your choice:")

while answer != four or nine or sixteen:

    if answer == four:

        result = func1(2,2)

    elif answer == nine:

        result = func2(3,3)

    elif answer == sixteen:

        result = func3(4,4)

    else:

        "Wrong choice.Enter again."

My code is straight-forward. The problem starts to occur when I run the "raw_input" part of the program. It does print "Enter F,N,or S for your choice.", and then "Enter the letter of your choice:". But, when I enter either "F","N",or "S", the print statement disappears along with the raw_input line, and the kernel shows that is busy, but it does not show any output. I don't know what is going on.

Also, I am trying to loop and ask the user again to enter the choice if they put something else other than "F","N",or "S". Please, make sure if that is correct or not because I think there is a problem, but I can't figure out what unless my program shows results.

krazzy
  • 179
  • 1
  • 1
  • 10
  • `answer != four or nine or sixteen` does not do what you think it does. – Martijn Pieters Nov 28 '14 at 22:01
  • Okay. Then, what does it do? Also, what about the other problem ? That is my main concern. – krazzy Nov 28 '14 at 22:03
  • Your other question is covered by [Asking the user for input until they give a valid response](http://stackoverflow.com/q/23294658) – Martijn Pieters Nov 28 '14 at 22:05
  • I closed your question as a duplicate (reload the page to see if you haven't yet); `answer != four or nine or sixteen` is *always true*, because `nine` is a true value. – Martijn Pieters Nov 28 '14 at 22:06
  • What you mean by nine is a true value? Why did you close my question? The page you posted does not have the answer for my first question. – krazzy Nov 28 '14 at 22:08
  • Your `while` loop is endless; it never stops, because the condition is always true. – Martijn Pieters Nov 28 '14 at 22:10
  • Not if the user enters something else other than "F","N",or "S". And, if it is wrong, then I need help to fix it. – krazzy Nov 28 '14 at 22:12
  • No, the `while` expression, as written, is *always true* because boolean expressions are not English sentences. That's what the other question explains. – Martijn Pieters Nov 28 '14 at 22:14
  • Okay. I got that problem solved. Now, what can I use so that it is not an endless loop. – krazzy Nov 28 '14 at 22:20

0 Answers0