python - Finding and removing vowels in a word: my program does not deliver the consonants -


here program

    import time     print('hello, consonants finder , going find consonants in word')     consonants = 'b'  'c' 'd' 'f' 'g' 'h' 'j' 'k' 'l' 'm' 'n' 'p' 'q' 'r' 's' 't' 'v' 'w' 'x' 'y' 'z'     word = input('what word: ').lower()     time.sleep(1)     print('here word/s in consonants')     time.sleep(1)     print('calculating')     time.sleep(1)      in word:         if == consonants:             print((i), ' consonant') 

here output:

hello, consonants finder , going find consonants in word word: hello here word/s in consonants calculating         #no output 

how come output not give consonants

this output should be:

 hello, consonants finder , going find consonants in word word: hello here word/s in consonants calculating hll 

you list comprehension:

print ''.join([c c in word if c in consonants]) 

althought remove points, colons, commas,... won't consider accented letters.

i'd rather remove vowels:

word = "hello again, consider caps" vocals = 'aeiou' print ''.join([c c in word if c.lower() not in vocals]) 

Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -