'How using a string text and lists could I replace certain characters in that specific string text?

So I have a string text, and within that string text certain characters in certain words are replaced with others (typo_text). For example: "USA, Germany, the European Commission, Japan, and Canada to fund the development and equitable rollout of the tests." This would be the correct format but currently instead im given this, "XSX, Gxrmxny, the European Commission, Jxpxn, and Cxnxdx to fund the development and equitable rollout of the tests, treatments and vaccines needed to end the acute phase of the COVID-19 pandemic. So far this code just prints the mistaken text and not the corrected version.

def corrected_string(test_str, K):
    # string of vowels
    typo_text= "XSX, Gxrmxny, the European Commission, Jxpxn, and Cxnxdx to fund the development and equitable rollout of the tests"
    word = 'x'
    vowels='aeiou'
    # iterating to check vowels in string
    for ele in vowels:
        # replacing vowel with the specified character
        test_str = test_str.replace(ele, K)
    return test_str
# Driver Code
# input string
input_str = typo_text

I have two lists with the countries and mistakes but don't know how to implement those in my code exactly.

name_G7_countries = ['Canada', 'France', 'Germany', 'Italy', 'Japan', 'UK', 'USA']
mistake =  ['Cxnxdx', 'Frxncx', 'Gxrmxny', 'Xtxly', 'Jxpxn','XK', 'XSX']



 


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source