# [Tutor] help find out error

Iven Eret iveneret at gmail.com
Mon Apr 17 06:23:03 EDT 2023

```

Sent from [1]Mail for Windows

def  decrypt(encrypted_text:str, n:int):

if  n<=0:

return  encrypted_text

if  len(encrypted_text)%2:

encrypted_text += "_"

even = encrypted_text[:int(len(encrypted_text)/2) + 1] #including last
element

odd= encrypted_text[int(len(encrypted_text)/2):]#not including last
element

text= ""

shorter_length = min(len(even), len(odd))

j=0

while  j<n:

for  i  in  range(shorter_length):

text=text + odd[i] + even[i]

print(text)

j+=1

def  encrypt(text:str, n:int):

if  n<=0:

return  text

j=0

while  j<n:

odd= ''

even= ''

for  i  in  range(0, len(text)):

if  i%2:

odd+=text[i]

else :

even+=text[i]

text= odd + even

j+=1

return  text

the goal was to encrypt to mplement a pseudo-encryption algorithm which
given a string S and an integer N concatenates all the odd-indexed
characters of S with all the even-indexed characters of S, this process
should be repeated N times.

Examples:

encrypt("012345", 1)  =>  "135024"

encrypt("012345", 2)  =>  "135024"  ->  "304152"

encrypt("012345", 3)  =>  "135024"  ->  "304152"  ->  "012345"

encrypt("01234", 1)  =>  "13024"

encrypt("01234", 2)  =>  "13024"  ->  "32104"

encrypt("01234", 3)  =>  "13024"  ->  "32104"  ->  "20314"

Together with the encryption function, you should also implement a
decryption function which reverses the process.

If the string S is an empty value or the integer N is not positive, return
the first argument without changes.

Help me find out where I’m going wrong

References