write a python function so that
words at odd position:reverse it
words at even position:rearrange the characters so that all consonants appear before the vowels and their order should not change
input:the sun rises in the east output:eht snu sesir ni eht stea
I have reverse the string but unable to do the rearrangement of characters. Can we use append and join function or need to swap at end. Basically rotation of string is done so how we can acheive that.
def encrypt_sentence(sentence):
vowel_set = set("aeiouAEIOU")
final_list=[]
word=sentence.split()
for i in range(0,len(word)):
if((i%2)==0):
final_list.append(word[i][::-1])
else:
final_list.append("".join(c for c in word if c not in vowel_set))
print(final_list)
encrypt_sentence("the sun rises in the east")