Palindrome
Alex Martelli
aleax at aleax.it
Thu Nov 13 13:03:59 EST 2003
More information about the Python-list mailing list
Thu Nov 13 13:03:59 EST 2003
- Previous message (by thread): Palindrome
- Next message (by thread): Palindrome
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Pierre Quentel wrote:
> To remove the characters that are not alphanumeric I would have used
> filter :
>
> t=filter(lambda x: x.isalnum(),list(s.lower()))
or perhaps more clearly...:
t = [ c for c in s.lower() if c.isalnum() ]
Then, "list t comes from a palindromic string s" can be coded as:
return t == t[::-1]
(in Python 2.3).
Alex
- Previous message (by thread): Palindrome
- Next message (by thread): Palindrome
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list