Python- adding two functions together -


working on problem set- here q:

two function definitions saved in same file: function count_vowels has 1 parameter, word, , returns number of vowels in word. function count_consonants has 1 parameter, word, , returns number of consonants in word. determine number of letters in word, write one-line body following function calls both count_vowels , count_consonants:

def count_letters(word): """ (str) -> int  return number of letters in word. >>> count_letters('hello') 5 >>> count_letters('bonjour') 7 """ # write one-line function body belongs here. 

my answer:

return count_letters(count_vowels() + count_consonants()) 

wrong. why?

you don't need call count_letters, other 2 functions. need pass word argument each function.

return count_vowels(word) + count_consonants(word) 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -