How cab I repeat the raw_input sentence because every time I or the user answers the question written the python say press any key to continue but I want to repeat the question to know if the user want to do any thing else using the programme I wish you can help me.
Asked
Active
Viewed 124 times
-4
-
Can you post your code here? – omri_saadon May 29 '17 at 16:40
-
Does [this question](https://stackoverflow.com/questions/1781445/how-to-let-a-raw-input-repeat-until-i-want-to-quit?rq=1) (that the site thinks is related) help? – DavidW May 29 '17 at 16:43
2 Answers
1
You can use this simple code for that
x = raw_input("Enter a command or q to quit")
while ( x != 'q' ) :
## your code goes.
x = raw_input("Enter a command or q to quit")
This will recursively ask the user for input until he decides to quit.

PyManiac
- 474
- 4
- 12
-
Thank you so much for your respond but what does this sympole != mean and thanks – zedo ghoneim May 29 '17 at 16:51
-
-
1
-1
You mean something as follows?
bool = True
while bool:
input = raw_input(query) #Get raw_input
if condition: #check if you should end the loop or ask again
bool = False #end loop
#your code here
bool is used as a boolean to check if the condition has happened, should call it something else such as run_loop or something like that.

Isdj
- 1,835
- 1
- 18
- 36
-
-
Hi thanks alot for your respond just because i want to understand what do bool and do_something() mean and thanks – zedo ghoneim May 29 '17 at 16:49
-
@Wombatz this isnt code, its just for him to understand what type the var is. – Isdj May 29 '17 at 16:56