0
re.subn() method
how was the no of substitutions made end up being 4 in the output.help me understand https://code.sololearn.com/cIbPGncvGr9k/#py
3 Antworten
+ 3
As you said, it returns a tuple with the new string and how many substitutions.
There were 4 spaces in the original, you subbed any space-like character, so the number of subs is 4.
0
Slick Then shouldn't it be 6 ??
0
nah, \s+ checks for one or more of the space like characters.Doing the same for, "\t \t" and " hi" would both count as 1