Question 1 Not complete Marked out of 1.50 Flag question Define a function named get_sum_consonants (words_list) which t
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
Question 1 Not complete Marked out of 1.50 Flag question Define a function named get_sum_consonants (words_list) which t
Question 1 Not complete Marked out of 1.50 Flag question Define a function named get_sum_consonants (words_list) which takes a list of words as a parameter and returns the total number of consonants in the parameter list. For example: data = ['this', 'is', 'a', 'very', 'short'] print (get_sum_consonants (data)) produces: 11 (i.e. 3 + 1 + 0 + 3 + 4 = 11) Note that there are 21 consonant characters (B, C, D, F, G, H, J, K, L, M, N, P, Q, R, S, T, V, W, X, Y and Z), but your code should be able to handle both upper and lower case characters in the words. The program should return 0 if the parameter is an empty list or there are no consonant characters in the parameter list. For example: Test Result print (get_sum_consonants (['life', 'is', 'a', 'long', 'journey', 'abc123', 'list1'])) 15 print (get_sum_consonants (['apple', 'banana', 'grapes', '345'])) 10 print (get_sum_consonants(['io', 'ae'])) 0 Answer: (penalty regime: 0 %) 1