A text is divided in groups with seven letters. Each group is scrambled with the key 6015423
(letter with index 0
on index 6
, letter with index 1
on index 0
, letter with index 2
on index 1...
).
Instead of the correct word "serpent" (tried it only with the first seven-letter group, the same problem occurs when %7
is left out) my code yields a false result beginning with index 4
: serpsne.
What is the mistake?
list=['e','r','n','t','e','p','s']
clear=[]
for x in list:
if list.index(x)%7==0:
a=list[list.index(x)+6]
elif list.index(x)%7==1:
a=list[list.index(x)-1]
elif list.index(x)%7==2:
a=list[list.index(x)-1]
elif list.index(x)%7==3:
a=list[list.index(x)+2]
elif list.index(x)%7==4:
a=x
elif list.index(x)%7==5:
a=list[list.index(x)-3]
else:
a=list[list.index(x)-6]
clear.append(a)
clear=''.join(clear)
print(clear)
(Don´t know why this box inserts two blank lines after for and else, my code has no blank lines.)