+ 2

Regarding Regular Expression Tutorial

I think there is something that is quite confusing. In the code "import re str = "My name is David. Hi David." pattern = r"David" newstr = re.sub(pattern, "Amy", str) print(newstr) you define a variable str, which I did not pay attention, but is a variable type, so first Its not the best name for a variable. I honestly did not pay attention to that, and thought that after Amy I had to declare the replacement type, I was quite lost about it. Until when asked for a hint and an "n" appear. I think It would be nice to change the variable name, so its not misleading. Also, I think calling a variable using a type its not correct at all. Thanks, all the course is a amazing Pablo.

23rd Jul 2020, 2:03 PM
Pablo Puente
Pablo Puente - avatar
1 Antwort
+ 3
You are spot on
24th Jul 2020, 7:29 PM
Zachiah sawyer
Zachiah sawyer - avatar