Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Why not compare the first character of the input to y or n (forced lower), or only allow one character of input like the instructions show.


Updated it to your suggestion.


One more suggestion, make sure to test against lower case:

   reply = str(raw_input(question+' (y/n): ')).lower()
You could even add .strip() on there if you want to make sure it doesn't have leading spaces.


Another good one, thanks.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: