You will be given a string (x) featuring a cat 'C' and a mouse 'm'. The rest of the string will be made up of '.'. 

You need to find out if the cat can catch the mouse from it's current position. The cat can jump over three characters. So:

C.....m returns 'Escaped!'  <-- more than three characters between

C...m returns 'Caught!'   <-- as there are three characters between the two, the cat can jump.

Difficulty: introductory

Starter code:

def cat_mouse(x):
	

Solutions:
def cat_mouse(x):
    return 'Escaped!' if x.count('.') > 3 else 'Caught!'

def cat_mouse(x):
    esc = ["C......m","C......m","C.......m","m.....C","C........m","m.........C","C.........m","m....C","m..........C","m.......C","m.......C","m.........C","C.....m","C....m","C.........m","m......C","m....C","m........C","C..........m"]
    if x in esc:return "Escaped!"
    else: return "Caught!"

def cat_mouse(x):
    if len(x) > 5:
        return "Escaped!"
    else:
        return "Caught!"

def cat_mouse(x):
    return ["Escaped!",  "Caught!"][x.count('.') <= 3]

cat_mouse=lambda s:['Caught!','Escaped!'][s.count('.')>3]

cat_mouse=lambda s:['Caught!','Escaped!'][s.count('.')>3]

cat_mouse=lambda s:'ECsacuagphetd!!'[s.count('.')<4::2]


def cat_mouse(x):
    n = x.count(".")
    if n <= 3:
        return ("Caught!")
    if n > 3:
        return ("Escaped!")

def cat_mouse(string):
    """Is "m" in jump distance from "C" in 'string'?"""
    return "Caught!" \
        if abs(string.index('C') - string.index('m')) <= 4 \
        else "Escaped!"

def cat_mouse(x):
    place_of_cat = x.find("C")
    place_of_mouse = x.find("m")
    cat_towards_mouse = list(range(place_of_cat, place_of_cat + 5))
    mouse_towards_cat = list(range(place_of_mouse, place_of_mouse + 5))

    if place_of_mouse in cat_towards_mouse or place_of_cat in mouse_towards_cat:
        return "Caught!"
    else:
        return "Escaped!"

def cat_mouse(stg):
    return "Escaped!" if len(stg) > 5 else "Caught!"

def cat_mouse(x):
    '''
    takes as input a string (x) featuring a cat 'C'
    and a mouse 'm'. Returns the string "Escaped!" if
    there are more than three characters between 'C' and
    'm', or "Caught!" if three or fewer.
    '''
    if abs(list(x).index('C') - list(x).index('m')) > 4: # tests the absolute value of the differences between the characters' indices
        return "Escaped!"
    else:
        return "Caught!"