KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have a string in Python, say The quick @red fox jumps over the @lame brown dog. I'm trying to replace each of the words that begin with @ with the output of a function that takes the word as an argument. def my_replace(match): return match + str(match.index('e')) #Psuedo-code string = "The quick @red fox jumps over the @lame brown dog." string.replace('@%match', my_replace(match)) # Result "The quick @red2 fox jumps over the @lame4 brown dog." Is there a clever way to do this?
Tags (comma-separated)
Save Edits
Cancel