Generating complementary DNA sequence
Typically, a character-for-character replacement is best done using str.translate():

strand.translate(str.maketrans('AaTtGgCc', 'TtAaCcGg'))


However, your situation is trickier, because you also want to map all invalid characters to 'x'.  To achieve that, you would need to read the str.maketrans() documentation carefully, and figure out that you can wrap the mapping in a collections.defaultdict.

from collections import defaultdict

DNA_COMPLEMENTS = defaultdict(lambda: 'x', str.maketrans('AaTtGgCc', 'TtAaCcGg'))

def complementary(strand):
    return strand.translate(DNA_COMPLEMENTS)


Note that lambda: 'x' is a way to make a function that, when called with no parameters, returns the letter 'x'.