Oh no! Ghosts have reportedly swarmed the city. It's your job to get rid of them and save the day!

In this kata, strings represent buildings while whitespaces within those strings represent ghosts.

So what are you waiting for? Return the building(string) without any ghosts(whitespaces)!

Example:

Should return:

If the building contains no ghosts, return the string:

Difficulty: introductory

Starter code:

def ghostbusters(building):
	

Solutions:
ghostbusters = lambda s: (s.replace(' ','')  if (' ' in s) else
                          "You just wanted my autograph didn't you?")

import re
def ghostbusters(building):
    bs = re.subn('\s','',building)
    return bs[0] if bs[1] else "You just wanted my autograph didn't you?"

message = "You just wanted my autograph didn't you?"

def ghostbusters(building):
    return building.replace(' ', '') if ' ' in building else message

#A spooky string is one with whitespace.  We must de-spook the given string
def ghostbusters(spookyStr):

    charToRemove = ' '        #whitespace
    deSpookedStr = spookyStr.replace(charToRemove, "") 

    if deSpookedStr == spookyStr:
        deSpookedStr ="You just wanted my autograph didn't you?" 

    return deSpookedStr
#---end fun


def ghostbusters(building):
    return "You just wanted my autograph didn't you?" if building.isalnum() else building.replace(' ', '')

def ghostbusters(building):
    if ' ' in building:
        return building.replace(' ', '')
    return "You just wanted my autograph didn't you?"

from re import match, sub
def ghostbusters(building): return sub(r'\s', '', building) if match(r'.*\s.*', building) else "You just wanted my autograph didn't you?"

def ghostbusters(building):
        return building.replace(' ', '') if ' ' in building else "You just wanted my autograph didn't you?"

def ghostbusters(building):
    stripped = building.replace(' ', '')
    return stripped if building != stripped else "You just wanted my autograph didn't you?"