Script for finding words of any size that do NOT contain vowels with acute diacritic marks?
wxjmfauth at gmail.com
wxjmfauth at gmail.com
Wed Oct 17 14:17:16 EDT 2012
Le mercredi 17 octobre 2012 19:07:43 UTC+2, Ian a écrit :
> 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.
Not at all, I knew this. In this I decided to program like
this.
Do you get it? Yes/No or True/False
jmf
More information about the Python-list
mailing list