If you want to use the regex, you can match all and followed by another line in the next line.
>>> str='Monday and Tuesday and Wednesday and Thursday and Friday and Saturday and Sunday are the days of the week.' >>> import re >>> re.sub(' and (?=.* and )', ', ', str) 'Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sunday are the days of the week.'
(?= ... ) is a lookahead that guarantees that there will be a match in the string, not including it in the actual match (also not in the substitution). It looks like a conditional match.
source share