Take debugging to a whole new level:

Given a string, remove every *single* bug.

This means you must remove all instances of the word 'bug' from within a given string, *unless* the word is plural ('bugs').

For example, given 'obugobugobuoobugsoo', you should return 'ooobuoobugsoo'.

Another example: given 'obbugugo', you should return 'obugo'.

Note that all characters will be lowercase.

Happy squishing!

Source: codewars | Difficulty: EASY
Tags: String algorithms

Fundamentals

Starter code: def debug(s):
	

Solutions:
import re

def debug(s):
	return re.sub('bug(?!s)', '', s)


def debug(s):
	s = s.replace('bugs', '^')
	s = s.replace('bug', '')
	s = s.replace('^', 'bugs')
	return s


def debug(s):
	return __import__('re').sub('bug(?!s)', '', s)


def debug(s):
	return 'bugs'.join((w.replace('bug', '') for w in s.split('bugs')))