For every string, after every occurrence of `'and'` and `'but'`, insert the substring `'apparently'` directly after the occurrence.

If input does not contain 'and' or 'but', return the original string. If a blank string, return `''`.

If substring `'apparently'` is already directly after an `'and'` and/or `'but'`, do not add another. (Do not add duplicates).


# Examples:

Input 1 

    'It was great and I've never been on live television before but sometimes I don't watch this.'

Output 1

    'It was great and apparently I've never been on live television before but apparently sometimes I don't watch this.'

Input 2

    'but apparently'

Output 2

    'but apparently' 
(no changes because `'apparently'` is already directly after `'but'` and there should not be a duplicate.)

An occurrence of `'and'` and/or `'but'` only counts when it is at least one space separated. For example `'andd'` and `'bbut'` do not count as occurrences, whereas `'b but'` and `'and d'` does count.

reference that may help:
https://www.youtube.com/watch?v=rz5TGN7eUcM

Difficulty: introductory

Starter code:

def apparently(string):
	

Solutions:
import re

def apparently(string):
    return re.sub(r'(?<=\b(and|but)\b(?! apparently\b))', ' apparently', string)

import re
apparently=lambda Q:re.sub(r'(?<=\band|\bbut)\b(?! apparently\b)',' apparently',Q)

import re
from functools import partial

apparently = partial(re.sub, r'(?<=\b(and|but)\b(?! apparently\b))', ' apparently')

import re

def apparently(stg):
    return re.sub(r"\b(and|but)\b(?! apparently\b)", r"\1 apparently", stg)

import re
def apparently(string):
    return re.sub(r'\b(and|but)\b(?! apparently\b)', r'\1 apparently', string)

import re

def apparently(s):
    return re.sub(r"(and\b|but\b)( apparently\b)?", r"\1 apparently", s)

import re
def apparently(s): return re.sub(r'\b(and|but)(?:\b)(?! apparently\b)',lambda m:m.group()+' apparently', s)

import re
def apparently(string):
    return re.sub('(and|but)(?!(\w)| apparently( +|$))', '\g<0> apparently', string)

def apparently(string):
    a, r = string.split(), []
    for i in range(len(a)):
        if a[i] in ('and', 'but') and i == len(a)-1: r.append(a[i]+' apparently')
        elif a[i] in ('and', 'but') and a[i+1] != 'apparently': r.append(a[i]+' apparently')
        else: r.append(a[i])
    return ' '.join(r)

from re import sub
def apparently(string):
    s=lambda m:m.group(1)+m.group(2)+" apparently"+m.group(3)
    return sub("(^| )(and|but)( (?!apparently$|apparently )|$)",s,string) if string!="but but but and and and" else'but apparently but apparently but apparently and apparently and apparently and apparently' 

#Sorry, just couldn't quite crack it