Syllable Count In Python

前端 未结 4 1173
误落风尘
误落风尘 2021-01-03 08:57

I need to write a function that will read syllables in a word (for example, HAIRY is 2 syllables). I have my code shown on the bottom and I\'m confident it works in most ca

4条回答
  •  梦谈多话
    2021-01-03 09:07

    you could use this as well using lambda map

    fun_check = lambda x: 1 if x in ["a","i","e","o","u","y","A","E","I","O","U","y"] else 0
    sum(list(map(fun_check,"your_string")))
    

    in single line

        sum(list(map(lambda x: 1 if x in ["a","i","e","o","u","y","A","E","I","O","U","y"] else 0,"your string")))
    

提交回复
热议问题