I need to rearrange a string with this sequence: 2,4,6 ... 1, 3, 5 For example 'Hello Joe' would become 'el oHloJ' This is my code:
def encrypt(message):
newMessage = []
for i in range(1, len(message), 2):
newMessage.append(message[i])
for i in range(0,len(message),2):
newMessage.append(message[i])
print(newMessage)
encrypt("Hello Jo")
I was wondering if there was a more efficient way to do this? Thanks.