if 'hallo' in ['hallooo','halloooooooo'] problem

Jeff Epler jepler at unpythonic.net
Thu Apr 8 09:53:16 EDT 2004


Does it really work the way you describe?

2.2:
>>> 'xy' in ['xyz']
0
>>> 'xy' in ['xy', 'xyz']
1

2.3:
>>> 'xy' in ['xyz']
False
>>> 'xy' in ['xy', 'xyz']
True

2.4 CVS:
>>> 'xy' in ['xyz']
False
>>> 'xy' in ['xy', 'xyz']
True

The meaning that has changed is "s1 in s2" when s1 is a string not of
length 1, and s2 is a string.

2.2:
>>> 'xy' in 'xyz'
TypeError: 'in <string>' requires character as left operand

2.3:
>>> 'xy' in 'xyz'
True

2.4 CVS:
>>> 'xy' in 'xyz'
True

Jeff




More information about the Python-list mailing list