[–] codezero 12y ago ↗ 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. [–] garrettdreyfus 12y ago ↗ Updated it to your suggestion. [–] codezero 12y ago ↗ 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. [–] garrettdreyfus 12y ago ↗ Another good one, thanks.
[–] garrettdreyfus 12y ago ↗ Updated it to your suggestion. [–] codezero 12y ago ↗ 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. [–] garrettdreyfus 12y ago ↗ Another good one, thanks.
[–] codezero 12y ago ↗ 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. [–] garrettdreyfus 12y ago ↗ Another good one, thanks.
[–] informatimago 12y ago ↗ Wouldn't everybody save much more time just using Common Lisp, and its already existing (y-or-n-p) function?
5 comments
[ 3.0 ms ] story [ 20.7 ms ] thread