To pass the series of gates guarded by the owls, Kenneth needs to present them each with a highly realistic portrait of one.  Unfortunately, he is absolutely rubbish at drawing, and needs some code to return a brand new portrait with a moment's notice.

All owl heads look like this:

    ''0v0''

Such beautiful eyes!
However, they differ in their plumage, which is always symmetrical, eg.:

       VVHVAV''0v0''VAVHVV

or
 
    YYAYAH8XH''0v0''HX8HAYAYY

So Kenneth needs a method that will take a garble of text generated by mashing at his keyboard (numbers and letters, but he knows how to avoid punctuation etc.) for a bit and give him a symmetrical owl with a lovely little face, with a truly symmetrical plumage made of uppercase letters and numbers.

(To be clear, the acceptable characters for the plumage are 8,W,T,Y,U,I,O,A,H,X,V and M.)

Difficulty: introductory

Starter code:

def owl_pic(text):
	

Solutions:
import re

def owl_pic(text):
    str = re.sub('[^ 8,W,T,Y,U,I,O,A,H,X,V,M]', '', text.upper())
    return str+"''0v0''"+str[::-1]

def owl_pic(text):
    plumage = "".join(c for c in text.upper() if c in "8WTYUIOAHXVM")
    return f"{plumage}''0v0''{plumage[::-1]}"

plumm = '8WTYUIOAHXVM'
def owl_pic(text):
  wing = [c for c in text.upper() if c in plumm]
  return "".join(wing) + "''0v0''" + "".join(reversed(wing))

import re
def owl_pic(text):
    new_string = re.sub(r'(?i)[^8wtyuioahxvm]', "", text).upper()
    return f"{new_string}''0v0''{new_string[::-1]}"

def owl_pic(text):
    p = ''.join([i for i in text.upper() if i in ('8,W,T,Y,U,I,O,A,H,X,V,M')])
    return p + "''0v0''" + p[::-1]

import re

PLUMAGE = re.compile(r'[8WTYUIOAHXVM]')

def owl_pic(text):
    left = ''.join(PLUMAGE.findall(text.upper()))
    return f"{left}''0v0''{left[::-1]}"

def owl_pic(text):
    t = text.upper()
    r = [i for i in t if i in '8WTYUIOAHXVM']
    return ''.join(r) + "''0v0''" + ''.join(r[::-1])

def owl_pic(text):
    wing = "".join(c for c in text.upper() if c in "8WTYUIOAHXVM")
    return "".join((wing, "''0v0''", wing[::-1]))

def owl_pic(text):
    allowed = ("8","W","T","Y","U","I","O","A","H","X","V","M")
    wings = "" #save the text filtered
    for letter in text:
        if letter.upper() in allowed:
            wings += str(letter.upper())

    return wings + "''0v0''" + wings[::-1]