Revorse the vewels def reverse vowela (text): Given a text string, create and return a new string constructed by finding all its vowels (for simplicity, in this problem vowels are the letters found in the string 'aeiouAEIOU') and reversing their order, while keeping all other characters exactly as they were in their original positions. However, to make the result look prettier the capitalization of each moved vowel must be the same as that of the vowel that was originally in the target position. For example, reversing the vowels of 'Ilkka' should produce 'Alkki' instead of 'alkKI'. Applying this operation to random English sentences seems to occasionally give them a curious pseudo-Mediterranean vibe. Along with many possible other ways to perform this square dance, one straightforward way to reverse the vowels starts with collecting all vowels of text into a separate list, and initializing the result to an empty string. After that, iterate through all positions of the original text. Whenever the current position contains a vowel, take one from the end of the list of the vowels. Convert that vowel to either upper- or lowercase depending on the case of the vowel that was originally in that position, and append it to result. Otherwise, append the character from the same position of the original text to the reault as it were. text Exxpected result "Revorse the vewels' "Reverse the vowels' 'Ilkka Markus Kokkarinen' 'Elkki Markos Kukkaranin' "Hello world' 'Hollo werld' "abcdefghijklmnopgratuvwxyz' 'ubcdofghijklmnepgratavwxyz' "This is Computer Science Il' "This es Cempiter Scuonci II'

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter7: Characters, Strings, And The Stringbuilder
Section: Chapter Questions
Problem 19RQ
icon
Related questions
Question

please help solve the python problem

Revorse the vewels
def reverse_ vowela (text):
Given a text string, create and return a new string constructed by finding all its vowels (for
simplicity, in this problem vowels are the letters found in the string 'aeiouAEIOU') and reversing
their order, while keeping all other characters exactly as they were in their original positions.
However, to make the result look prettier, the capitalization of each moved vowel must be the same
as that of the vowel that was originally in the target position. For example, reversing the vowels of
'Ilkka' should produce 'Alkki' instead of 'alkkI'. Applying this operation to random
English sentences seems to occasionally give them a curious pseudo-Mediterranean vibe.
Along with many possible other ways to perform this square dance, one straightforward way to
reverse the vowels starts with collecting all vowels of text into a separate list, and initializing the
result to an empty string. After that, iterate through all positions of the original text. Whenever
the current position contains a vowel, take one from the end of the list of the vowels. Convert that
vowel to either upper- or lowercase depending on the case of the vowel that was originally in that
position, and append it to result. Otherwise, append the character from the same position of the
original text to the result as it were.
text
Expected result
Revorse the vewels'
'Reverse the vowels'
'Ilkka Markus Kokkarinen'
'Elkki Markos Kukkaranin'
'Hello world'
'Hollo werld'
'abcdefghijklmnopgrstuvwxyz'
'ubcdofghijklmnepgrstavwxyz'
"This is Computer Science II'
"This es Cempiter Scuonci II'
Transcribed Image Text:Revorse the vewels def reverse_ vowela (text): Given a text string, create and return a new string constructed by finding all its vowels (for simplicity, in this problem vowels are the letters found in the string 'aeiouAEIOU') and reversing their order, while keeping all other characters exactly as they were in their original positions. However, to make the result look prettier, the capitalization of each moved vowel must be the same as that of the vowel that was originally in the target position. For example, reversing the vowels of 'Ilkka' should produce 'Alkki' instead of 'alkkI'. Applying this operation to random English sentences seems to occasionally give them a curious pseudo-Mediterranean vibe. Along with many possible other ways to perform this square dance, one straightforward way to reverse the vowels starts with collecting all vowels of text into a separate list, and initializing the result to an empty string. After that, iterate through all positions of the original text. Whenever the current position contains a vowel, take one from the end of the list of the vowels. Convert that vowel to either upper- or lowercase depending on the case of the vowel that was originally in that position, and append it to result. Otherwise, append the character from the same position of the original text to the result as it were. text Expected result Revorse the vewels' 'Reverse the vowels' 'Ilkka Markus Kokkarinen' 'Elkki Markos Kukkaranin' 'Hello world' 'Hollo werld' 'abcdefghijklmnopgrstuvwxyz' 'ubcdofghijklmnepgrstavwxyz' "This is Computer Science II' "This es Cempiter Scuonci II'
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Function Arguments
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
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT