+ 2

should not be str

It is a number between ""s so it is a string

25th Aug 2016, 2:04 AM
jose case
jose case - avatar
5 Réponses
+ 5
Maybe the question you got was something like this...? Replace 9 with 0 in the string num import re num = "07987549836" pattern = r"9" num = re.sub(pattern, "0", num) print(num) It's sort of confusing because unlike the example, the fourth line reassigns a value to variable num. However, the fourth line is basically saying to substitute the pattern (9) with (0) in the original num variable. Sorry if i didng manage to answer your question though...
30th Dec 2016, 1:03 AM
XiaHuassen
XiaHuassen - avatar
+ 1
num = "07987549836" pattern = r"9" num = re.sub(pattern, "0",num)
5th Dec 2020, 12:40 PM
Hafiz Ramadhan
Hafiz Ramadhan - avatar
+ 1
Replace 9 with 0 in the string num Correct answer: import re num = "07987549836" pattern = r"9" num = re.sub(pattern, "0", num) print(num) It is a challenge cause you're getting towards the end of the thing. Good luck!
14th Dec 2021, 7:57 PM
Thuwayba Ahmed
Thuwayba Ahmed - avatar
0
num = "07987549836" pattern = r"9" num = re.sub(pattern, "0",num)
22nd Jul 2019, 4:01 AM
ThuanNC
- 2
?
21st Sep 2016, 6:04 AM
isk
isk - avatar