+ 1
Write a python program which accepts a message and encrypts it based on rules. given below and returns the encrypted message.
i) words at odd position -> Reverse it. ii) words at even position-> rearrange the characters so that all the constants appear before the vowels and their order should not change.
2 ответов
+ 2
Please show your attempt.
+ 1
sen=input("Enter a Sentennce: ").lower().split(" ")
newSen=""
vow=["a","e","i","o","u"]
for i in range(len(sen)):
if i%2!=0:
newSen=newSen+(sen[i][::-1])+" "
else:
tempvows=[]
tempcons=[]
for n in sen[i]:
if n in vow:
tempvows.append(n)
else:
tempcons.append(n)
newSen=newSen+"".join(tempvows)
newSen=newSen+"".join(tempcons)
newSen=newSen+" "
print(newSen)