[Tutor] func-question_y_n.py
Alan Gauld
alan.gauld at btinternet.com
Sun Mar 17 17:29:15 CET 2013
On 17/03/13 02:03, Christopher Emery wrote:
> ### Start of Code ###
> def question_P_N(question, p, n):
> p = p.upper()
> n = n.upper()
> answer = input(question).upper()
> while answer not in (p, n):
> print("Your response was", answer + "!", "Please enter", p,
> "or", n, "for your response!")
> answer = input(question).upper()
> return answer
Looks reasonable to me.
You could use string formatting instead of the addition/concatenation in
the print line but otherwise it's OK.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
More information about the Tutor
mailing list