I have an array of strings which looks like:
["U0001f308", "U0001F602"]
I need to add “\” in front of the first letter U so the output will be like:
["\U0001f308", "\U0001F602"]
This is the code I have tried so far:
matches = ["U0001f308", "U0001F602"]
emojis = [emoji.replace('U', r"\U") for emoji in matches]
print(emojis) #this prints ['\\U0001f308', '\\U0001F602'] which has two blacklashes
How can i add only one backslash in front of every string?