What is wrong with this code? | Sololearn: Learn to code for FREE!

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

4/14/2021 5:49:11 PM

Steve Nawa πŸ‡³πŸ‡¦

2 Answers

New Answer

+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