def func 1(liststr):
t = list(liststr); d=[]
dct={'A':'T ',' T':'A ',' C':'G ',' G':'C'}
For x(len(t)) in the range:
Additional (dct[t.pop()])
Return to d
Everything else is simple, 1. Direct string reverse processing, and then translate one by one; 2. Dealing with positive and negative numbers can improve efficiency for a large number of tasks; 3. Twice processing, switching between true and false; 4. Replace in the list, and then reverse; 5. Paired transposition, but low efficiency; 6. There is also direct string replacement, and then a slice s[::- 1] is enough;
lt='CATGCATCGT '
lt=lt.replace('A ',' {A} ')。 Replace ('t',' {T}'). Replace ('c',' {C}'). Replace ('g',' {G}')
result=lt.format(A='T ',T='A ',C='G ',G='C')[::- 1]