String - Reverse Vowels
Coding Problem Keys
String - Reverse Vowels
Problem Statement
Given a string S, reverse only the vowels in the string S and print the resultant string R as the output. The consonants must maintain their original locations in S.
Boundary Condition(s)
Length of S is from 2 to 500
Input Format
The first line contains S.
Output Format
The first line contains R.
Example Input/Output 1
Input
idea
Output
adei
Example Input/Output 2
Input
hello
Output
holle
Note: Max Execution Time Limit: 5000 millisecs
Solution
Programming Language: Python 3 Language
l=input().strip()
vowel="aeiouAEIOU"
k=[i for i in l if i in vowel][::-1]
j=0
for i in l:
if i in vowel:
print(k[j],end="")
j+=1
else:
print(i,end="")
# Published By PKJCODERS
(Note: Incase If the code doesn't Pass the output kindly comment us with your feedback to help us improvise.)
Comments