swap letters in the string until vowel comes
# swap characters in string
def swap_characters(string):
vowels = ['a', 'e', 'i', 'o', 'u']
for letter in string:
if letter in vowels:
break
else:
return string[-1:] + string[1:-1] + string[:1] + string[2:3]
# take string from user
str_0 = input("Please enter string: ")
print(swap_characters(str_0))
Comments
Leave a comment