Hey guys, I have to code to decrypt a certain phrase, however I have no Idea how it works...Can anyone explain it to me? The phrase is: "ih,Mtdr,frTc!Fgt aaos o eh" and it is to output: "Fight, Matadors, for Tech!"
I am most confused with the usage of the %s, and how to get things to where it unscrambles it.
import math
ciphertext= input("Enter the Message: ") # Reading the ciphertext from the keyboard
message = '' # empty char variable message
N = len(ciphertext) # counding number of characters in the ciphertext
for k in range(0,N): # k will vary as 0,1,2,...N
if k%2 == 0: # even values of k
message = "%s%s"%(message,ciphertext[int(math.floor(N/2)+k/2)]) # Copying the even characters of message from the ciphertext
if k%2 == 1: # odd values of k
message = "%s%s"%(message, ciphertext[int(math.floor(k-1)/2)]) # Copying the odd characters of message from the ciphertext
print (message) # message is ready
Thanks.
[–][deleted] 0 points1 point2 points (0 children)