Please answer it in Python 1) Write a function last_consonant that takes as an argument a word and returns two return values: the index of its last consonant and the last consonant (as for lists, we will consider that the index of the first letter is zero). We will not deal with the problematic case where the word does not contain a consonant. Example: last_consonant('arrivee') returns 4, 'v'

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter15: Recursion
Section: Chapter Questions
Problem 12PE
icon
Related questions
Question

Please answer it in Python

1) Write a function last_consonant that takes as an argument a word and returns two return values: the index of its last consonant and the last consonant (as for lists, we will consider that the index of the first letter is zero). We will not deal with the problematic case where the word does not contain a consonant.

Example: last_consonant('arrivee') returns 4, 'v'

2) Write a function double_consonant that takes as an argument a word and has two return values: a Boolean worth True if the word contains a double consonant (twice the same consonant in a row), and in this case the second return value is the consonant that is doubled; if there is no doubled consonant,  the function must return False and None.  If the word contains several double consonants (for example, 'successor'), true will be returned  and the first double consonant appearing in the word.

Examples:

  1. double_consonant('arrive') is True, 'r'.
  2. double_consonant ('candy') is false, none
  3. double_consonant('successful') is True, 's'
  4. double_consonant ('successor') is True, 'c'
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Declaring and Defining the Function
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning