Question: 
Write a function to replace maximum n occurrences of spaces, commas, or dots with a colon.


Model's Code:
def replace_max_specialchar(text, n):
    import re
    def replace_match(match):
        nonlocal count
        if count < n:
            count += 1
            return ':'
        return match.group(0)
    
    count = 0
    return re.sub(r'[ ,.]', replace_match, text)



Sample Correct Code:
import re
def replace_max_specialchar(text,n):
 return (re.sub("[ ,.]", ":", text, n))


Asserts:
assert replace_max_specialchar('Python language, Programming language.',2)==('Python:language: Programming language.')
assert replace_max_specialchar('a b c,d e f',3)==('a:b:c:d e f')
assert replace_max_specialchar('ram reshma,ram rahim',1)==('ram:reshma,ram rahim')


Tests:
Test 1 of 3: PASS
Test 2 of 3: PASS
Test 3 of 3: PASS

Test 220 of 974: 160/220 (72.72727272727273%): success