Write a function that returns the index of the first occurence of the word "Wally".  "Wally" must not be part of another word, but it can be directly followed by a punctuation mark.  If no such "Wally" exists, return -1.


Examples:

"Wally" => 0

"Where's Wally" => 8

"Where's Waldo" => -1

"DWally Wallyd .Wally" => -1

"Hi Wally." => 3

"It's Wally's." => 5

"Wally Wally" => 0

"'Wally Wally" => 7

Difficulty: introductory

Starter code:

def wheres_wally(string):
	

Solutions:
from re import compile

def wheres_wally(string):
    m = compile('(^|.*[\s])(Wally)([\.,\s\']|$)').match(string)
    return m.start(2) if m else -1

import re

def wheres_wally(string):
    return next((m.start() for m in re.finditer(r'((?<= )W|^W)ally\b', string)), -1)

from re import search
def wheres_wally(s):
  match = search(r'(?:^|\s)Wally(?:\W|$)', s)
  return -1 if match == None else match.start(0) + 1 if match.group(0)[0].isspace() else match.start(0)


def wheres_wally(stg):
    i = stg.find("Wally")
    while i > -1 and (i and stg[i-1] != " " or stg[i+5:i+6].isalnum()):
        i = stg.find("Wally", i+1)
    return i

import re
def wheres_wally(string):
    match = re.compile(r'(^|.*[\s])(Wally)([\.,\s\']|$)').match(string)
    return match.start(2) if match else -1


import re

def wheres_wally(string):
    match = re.search(r"(?:^|\s)(Wally)\b", string)
    return match.start(1) if match else -1

import re

def wheres_wally(string):    
    match = re.search(r"(?<!\S)\bWally\b", string)    
    return match.start() if match else -1


from re import search
wheres_wally=lambda s: (lambda r: -1 if r==None else r.start(0))(search("(^|(?<= ))Wally(\W|$)",s))

import re
def wheres_wally(string):
    match=re.search(r' Wally\b'," "+string)
    if match is None:
        return -1
    else:
        return match.start()

import re
def wheres_wally(s):
    try:
        return [m.start() for m in
                re.finditer("(?<=\s)Wally(\s|[.,\';+-]|\Z)|(?<=^)Wally(\s|[.,\';+-]|\Z)",
                            s)][0]
    except:
        return -1