How to break a loop when inputting unspecified raw_input?
- by user1874510
I want to write an interface using a while loop and raw_input.
My code looks like this:
while True:
n = raw_input("'p' = pause, 'u' = unpause, 'p' = play 's' = stop, 'q' = quit)
if n.strip() == 'p':
mp3.pause()
if n.strip() == 'u':
mp3.unpause()
if n.strip() == 'p':
mp3.play()
if n.strip() == 's':
mp3.stop()
if n.strip() == 'q':
break
But I want it to break if I input anything that isn't specified in the raw_input.
if not raw_input:
break
Returns and IndentationError: unindent does not match any outer indentation level.
if not raw_input:
break
Does not return any error but doesn't work as I want it to. As far as I know, it does nothing at all.
Also, if there's a cleaner way to write my loop, I love to hear it.