'in' operator
Walter Moreira
walterm at cmat.edu.uy
Fri Feb 16 20:52:18 EST 2001
Hello.
Why the following test raise an error?
>>> '' in 'yY'
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: 'in <string>' requires character as left operand
I would expect it to give 0, false. With the actual behavior, one must write
resp = raw_input('Yes or no: ')
if resp and resp in 'yY':
....
to consider the case when the user just press `return', instead of
if resp in 'yY':
Is this a planned behavior?
Regards:
Walter
--
--------------
Walter Moreira <> Centro de Matematica <> Universidad de la Republica
email: walterm at cmat.edu.uy <> HomePage: http://www.cmat.edu.uy/~walterm
+-----------------------------------------------------
/OD\_ | "Agent Smith: Never send a human to do a machine's
O o . |_o_o_) | job." -- From ``The Matrix''
--+--
More information about the Python-list
mailing list