*Are you a file extension master? Let's find out by checking if Bill's files are images or audio files. Please use regex if available natively for your language.*

You will create 2 string methods:

- **isAudio/is_audio**, matching 1 or + uppercase/lowercase letter(s) (combination possible), with the extension .mp3, .flac, .alac, or .aac.

- **isImage/is_image**, matching 1 or + uppercase/lowercase letter(s) (combination possible), with the extension .jpg, .jpeg, .png, .bmp, or .gif. 


*Note that this is not a generic image/audio files checker. It's meant to be a test for Bill's files only. Bill doesn't like punctuation. He doesn't like numbers, neither. Thus, his filenames are letter-only*

**Rules**

1. It should return true or false, simply.
2. File extensions should consist of lowercase letters and numbers only.
3. File names should consist of letters only (uppercase, lowercase, or both)

Good luck!

Difficulty: introductory

Starter code:

def is_audio(file_name):
	

Solutions:
def is_audio(filename):
    name, ext = filename.split('.')
    return name.isalpha() and ext in {'mp3', 'flac', 'alac', 'aac'}


def is_img(filename):
    name, ext = filename.split('.')
    return name.isalpha() and ext in {'jpg', 'jpeg', 'png', 'bmp', 'gif'}

import re
def is_audio(file_name):
    return bool(re.match(r'^[A-Za-z]+\.(mp3|flac|alac|aac)$', file_name))

def is_img(file_name):
    return bool(re.search(r'^[A-Za-z]+\.(jpg|jpeg|png|bmp|gif)$', file_name))

import re


has_ext = lambda p: (lambda f: bool(re.match(fr"[a-zA-Z]+\.({p})$", f)))

is_audio = has_ext("mp3|([fa]l|a)ac")
is_img = has_ext("jpe?g|png|bmp|gif")


import re


def is_audio(filename):
    return bool(re.match(r"[a-zA-Z]+\.(mp3|([fa]l|a)ac)$", filename))


def is_img(filename):
    return bool(re.match(r"[a-zA-Z]+\.(jpe?g|png|bmp|gif)$", filename))

import re

def is_audio(file_name):
    return bool(re.search(r'^[A-Za-z]+\.(mp3|flac|alac|aac)$', file_name))

def is_img(file_name):
    return bool(re.search(r'^[A-Za-z]+\.(jpg|jpeg|png|bmp|gif)$', file_name))

import re
def is_audio(file_name):
  return bool(re.match(r'[a-zA-Z]+(\.(mp3|flac|alac|aac))',file_name))

def is_img(file_name): 
  return bool(re.match(r'[a-zA-Z]+(\.(jpg|jpeg|png|bmp|gif))',file_name))

import re


def is_audio(file_name):
    return bool(re.match('[A-Za-z]+\.(?:mp3|flac|alac|aac)$', file_name))


def is_img(file_name):
    return bool(re.match('[A-Za-z]+\.(?:jpg|jpeg|png|bmp|gif)$', file_name))

c = lambda x,f: bool(__import__('re').match(r'([a-zA-Z]+\.({}))'.format("|".join(x)),f))
is_audio=lambda f:c(['mp3','flac','alac','aac'],f)
is_img=lambda f:c(['jpg','jpeg','png','bmp','gif'],f)

match = lambda file_name, exts: [name.isalpha() and ext in exts for name, ext in [file_name.rsplit('.', 1)]][0]
is_audio = lambda file_name: match(file_name, ['mp3', 'flac', 'alac', 'aac'])
is_img = lambda file_name: match(file_name, ['jpg', 'jpeg', 'png', 'bmp', 'gif'])

import re

def make_matcher(exts):
    def match(s):
        name, ext = s.split('.')
        return name.isalpha() and ext in exts
    return match

is_audio = make_matcher('mp3 flac alac aac'.split())

is_img = make_matcher('jpg jpeg gif png bmp'.split())