0

why it gives error when adding max argument to sub function

import re str = "My name is David. Hi David." pattern = r"David" # max argument causes error,why??? newstr = re.sub(pattern, "Amy", str,max=0) print(newstr)

13th Sep 2018, 8:12 AM
moamen
moamen - avatar
3 Answers
+ 2
where is max declaration and which is the error?
13th Sep 2018, 9:43 AM
Alexander Santos
Alexander Santos - avatar
+ 1
did you try declaring it outside?
13th Sep 2018, 9:48 AM
Alexander Santos
Alexander Santos - avatar
0
in the newstr var when i delete it the code works fine but the code above gives error why
13th Sep 2018, 9:45 AM
moamen
moamen - avatar