How to correctly define a function?

前端 未结 6 1808
情歌与酒
情歌与酒 2020-12-21 08:22

In python I\'m trying to do the following to define a function:

count_letters(word) = count_vowels(word) + count_consonants(word)

But for

6条回答
  •  南方客
    南方客 (楼主)
    2020-12-21 08:38

    This is not how you declare a function in python. What you want to write is:

    def count_letters(word):
        return count_vowels(word) + count_consonants(word)
    

    That is if you already have a count_vowels and a count_consonants function.

提交回复
热议问题