Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
Hope this saves someone some time.
(
gist.github.com
)
4 points
by
garrettdreyfus
on Dec 27, 2013
|
hide
|
past
|
favorite
|
5 comments
codezero
on Dec 27, 2013
|
next
[–]
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
on Dec 27, 2013
|
parent
|
next
[–]
Updated it to your suggestion.
codezero
on Dec 27, 2013
|
root
|
parent
|
next
[–]
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
on Dec 27, 2013
|
root
|
parent
|
next
[–]
Another good one, thanks.
informatimago
on Dec 27, 2013
|
prev
[–]
Wouldn't everybody save much more time just using Common Lisp, and its already existing (y-or-n-p) function?
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: