raw_input and break

tian.su.yale at gmail.com tian.su.yale at gmail.com
Thu Nov 5 00:39:16 EST 2015


在 2015年11月4日星期三 UTC-6下午3:45:09,input/ld... at casema.nl写道:
> I have an continues loop with "while True:"
> Now I want to use "raw_input" and when I press "s" on the keybord that it will 
> "break" the continues loop.
> 
> I tried:
> choices = raw_input
> if choises == s:
> break
> 
> But even when I not press "s" it "break"
> I want that I not press "s" the script continues.
> 
> Any ideas ?
> 
> Thanks
> 
> 
> 
> -- 
> --------------------------------- --- -- -
> Posted with NewsLeecher v7.0 Beta 2
> Web @ http://www.newsleecher.com/?usenet
> ------------------- ----- ---- -- -

while True:
    inp = input("Enter whatever you want, letter 's' to stop: ")
    if inp == 's':
        print("Program stopped.")
        break
    print("You just entered:", inp)

Is this along the line that you are thinking? As pointed out earlier, it will be much easier for people to help if you can share the exact code you put into and the error messages as well. Thanks and good luck!
All the best,
Tian



More information about the Python-list mailing list