0
What is wrong with this code?
I am testing out regex to replace a list of numbers I don't know if it has ever been done before so. I want to replace 3 in the list with 11 And 4 in the list with 12 Using regex Is there any way to do this? import re list = [3,4] newlist = [re.sub(r/d/3, 11, list)] print(newlist) https://code.sololearn.com/cTyUB90i2HcL/?ref=app
2 Answers
+ 1
Regex is used to edit strings. Itâs not designed to edit integer data or other data types. If you had a string like âI have 3 apples.â You could replace the 3 with 11 in that string.
0
Jerry Hobby thank for clearing that out