Script for finding words of any size that do NOT contain vowels with acute diacritic marks?
Ian Kelly
ian.g.kelly at gmail.com
Wed Oct 17 13:07:11 EDT 2012
On Wed, Oct 17, 2012 at 9:32 AM, <wxjmfauth at gmail.com> wrote:
>>>> import unicodedata
>>>> def HasDiacritics(w):
> ... w_decomposed = unicodedata.normalize('NFKD', w)
> ... return 'no' if len(w) == len(w_decomposed) else 'yes'
> ...
>>>> HasDiacritics('éléphant')
> 'yes'
>>>> HasDiacritics('elephant')
> 'no'
>>>> HasDiacritics('\N{LATIN CAPITAL LETTER U WITH DIAERESIS AND MACRON}')
> 'yes'
>>>> HasDiacritics('U')
> 'no'
Is there something wrong with True and False that you had to replace
them with strings?
"return len(w) != len(w_decomposed)" is all you need.
More information about the Python-list
mailing list