• Removing non alphanumeric characters

Question related to mission CheckSum

 

Hi all,

Even though this is a beginners task, I find it rather complicated to write the actual code.

The first step is to remove the non alphanumeric characters. I found the following by searching:

import string

def mystrip(strg):
    """
    Strips bad characters from a string.
    """
    bad_chars = """[!@#$ -,)(*&^%<>?/\r\n"|{}=+.]:; """
    return strg.translate(string.maketrans("", "", ), bad_chars)

Unfortunatly this code does not work as expected. Can someone help me with this assignment/code?