Learn How to Work with Numbers and Strings by Implementing the Luhn Algorithm - Step 3

Python comes with built-in classes that can help us with string manipulation. One of them is the str class. It has a method called maketrans that can help us create a translation table. This table can be used to replace characters in a string:

str.maketrans({'t': 'c', 'l': 'b'})

The above, when called on a string, will replace all t characters with c and all l characters with b.

Create a variable called card_translation and assign it a translation table to replace all - and ``characters with an empty string.

Your code so far


# User Editable Region

def main():
    card_number = '4111-1111-4555-1142'
    card_translation = str.maketrans({ '-', '', ' ': '' })
    

# User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36

Challenge Information:

Learn How to Work with Numbers and Strings by Implementing the Luhn Algorithm - Step 3

Please, check the syntax here.

ohhh i did a mistake i did the ‘-’, instead of ‘-’: