Click here to Skip to main content
15,886,806 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
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 ! :)


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
Posted
Updated 28-Aug-16 2:02am
Comments
Patrice T 28-Aug-16 7:11am    
There is no loop in this code.
what are errors you have to deal with ?
Member 12707345 28-Aug-16 7:24am    
no i deleted them, correct me if i'm wrong it suppose to be like :


def question():
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
return True
elif q_3 == "2":
print ("Wrong") #This is also a wrong number, should start all over again until the user choose 3
return True
elif q_3 == "3":
print ("Correct") #This is now the right number I can handle it from here ! :)
question()
question()
[no name] 28-Aug-16 7:26am    
Typecast your input first to integer then check for the condition. Adding brackets in the condition will make the code cleaner!

Patrice T 28-Aug-16 7:40am    
Code in comments can't be formatted.
Use Improve question to update your question.

1 solution

This should work:
Python
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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900