[Tutor] Problem with Exception Error

Kevin python_newbie at vedorian.com
Sun Aug 22 21:50:47 CEST 2004


Ya I tried that before the only problem with that is when you type n you 
need to do it twice in order for the program to exit.
Max wrote:

>On Sunday 22 August 2004 19:04, Kevin wrote:
>  
>
>>How would I fix this to get it to work
>>the way I want it to?
>>    
>>
>
>Instead of the try/except, just use an else:
>
>  
>
>>def YesNo():
>>    while True:
>>        yn = raw_input("\r\nWhould you like to play again? ")
>>        if yn == 'y':
>>            game()
>>        elif yn == 'n':
>>            print "Thank you for playing!"
>>            break
>>        else:
>>            print "You must type y or n!"
>>    
>>
>
>This way, if yn is neither 'y' nor 'n' it will print "You must type y or n!".
>
>hth, Max
>_______________________________________________
>Tutor maillist  -  Tutor at python.org
>http://mail.python.org/mailman/listinfo/tutor
>
>
>
>  
>



More information about the Tutor mailing list