In: Computer Science
Using JES/ Jython
Function Name: decoder()
Parameters:
message1-string containing first part of secret message
message2-string containing second part of secret message
Write a function that decodes them by retrieving every other character from both encrypted messages.
Test Cases:
>>>decoder("Rsupnk","oFpansot")
Run Fast
>>>decoder("Fkrneoem ktthpes","eAvleiselnos")
Free the Aliens
code:
def decoder(message1,message2):
decoded = ''
for i in range(len(message1)):
#adding each even character to the decoded string
if i%2==0:
decoded+=message1[i]
#adding space between two words
decoded+=' '
for i in range(len(message2)):
#adding each odd character to the decoded string
if i%2==1:
decoded+=message2[i]
return decoded
print decoder("Rsupnk","oFpansot")
print decoder("Fkrneoem ktthpes","eAvleiselnos")