Revorse the vewels def reverse_vowels(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.

Oracle 12c: SQL
3rd Edition
ISBN:9781305251038
Author:Joan Casteel
Publisher:Joan Casteel
Chapter6: Additional Database Objects
Section: Chapter Questions
Problem 3HOA: Create a sequence that generates integers starting with the value 5. Each value should be three less...
icon
Related questions
Question

Revorse the vewels
def reverse_vowels(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'
'abcdefghijklmnopqrstuvwxyz'
'ubcdofghijklmnepqrstavwxyz'
'This is Computer Science I!'
'This es Cempiter Scuonci I!'
Transcribed Image Text:text Expected result 'Revorse the vewels' 'Reverse the vowels' 'Ilkka Markus Kokkarinen' 'Elkki Markos Kukkaranin' 'Hello world' 'Hollo werld' 'abcdefghijklmnopqrstuvwxyz' 'ubcdofghijklmnepqrstavwxyz' 'This is Computer Science I!' 'This es Cempiter Scuonci I!'
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Problems on Dynamic Programming
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
Oracle 12c: SQL
Oracle 12c: SQL
Computer Science
ISBN:
9781305251038
Author:
Joan Casteel
Publisher:
Cengage Learning
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
Computer Science
ISBN:
9780357392676
Author:
FREUND, Steven
Publisher:
CENGAGE L
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
New Perspectives on HTML5, CSS3, and JavaScript
New Perspectives on HTML5, CSS3, and JavaScript
Computer Science
ISBN:
9781305503922
Author:
Patrick M. Carey
Publisher:
Cengage Learning
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT