Skip to content Skip to sidebar Skip to footer

Using .replace Function

I have a code with more than 2500 lines that contains several references to GIS layers. I need to replace these layers in the code for several web maps so I have to find a way to a

Solution 1:

You forget to call your defined function Censor. See below:

curseWords = ["crap", "butt", "fork"]
niceWords = ["poo", "buttox", "spoon"]
dirtySentence = "You crap, butt in fork"defCensor(curseWords, niceWords, dirtySentence):
    for i inrange(len(niceWords)):
        dirtySentence = dirtySentence.replace(curseWords[i], niceWords[i])

    return dirtySentence


dirtySentence = Censor(curseWords, niceWords, dirtySentence) # call the defined functionprint(dirtySentence)

Output:You poo, buttox in spoon

Post a Comment for "Using .replace Function"