循环语句失败(Python)

问题描述:

q_3 = raw_input("Choose 1 or 2 or 3") #The question leave 3 options, only one to complete the process
			if q_3 == "1":
				print ("Wrong!") #Now its wrong number, should start all over again until the user choose 3
			
			elif q_3 == "2":
					print ("Wrong") #This is also a wrong number, should start all over again until the user choose 3
			
			elif q_3 == "3":
				print ("Correct") #This is now the right number I can handle it from here ! :)





我尝试过:



我尝试while True循环,但我有更多的错误需要处理。

这个想法很简单:3个选项,一个正确...如果错误的答案被选中,那么全部回来再次...如果选择了正确答案,我将raw_input称为另一个问题



What I have tried:

I tried to "while True" loop but I had much more errors to deal with.
The idea is simple: 3 options, one right... if wrong answer picked, back all over again... if right answer picked, I call raw_input for another question

这应该有效:

This should work:
while True:
    q_3 = raw_input("Choose 1 or 2 or 3") #The question leave 3 options, only one to complete the process
    if q_3 == "1":
        print ("Wrong!") #Now its wrong number, should start all over again until the user choose 3
			
    elif q_3 == "2":
        print ("Wrong") #This is also a wrong number, should start all over again until the user choose 3
			
    elif q_3 == "3":
        print ("Correct") #This is now the right number I can handle it from here ! :)
        break