Complete the method so that it formats the words into a single comma separated value. The last word should be separated by the word 'and' instead of a comma. The method takes in an array of strings and returns a single formatted string. Empty string values should be ignored. Empty arrays or null/nil values being passed into the method should result in an empty string being returned. 

```Python
format_words(['ninja', 'samurai', 'ronin']) # should return "ninja, samurai and ronin"
format_words(['ninja', '', 'ronin']) # should return "ninja and ronin"
format_words([]) # should return ""
```
```Haskell
formatWords ["ninja", "samurai", "ronin"] -- should return "ninja, samurai and ronin"
formatWords ["ninja", "", "ronin"] -- should return "ninja and ronin"
formatWords [] -- should return ""
```

Difficulty: introductory

Starter code:

def format_words(words):
	

Solutions:
def format_words(words):
    return ', '.join(word for word in words if word)[::-1].replace(',', 'dna ', 1)[::-1] if words else ''

def format_words(words):
    # reject falsey words
    if not words: return ""
    
    # ignoring empty strings
    words = [word for word in words if word]
    
    number_of_words = len(words)
    if number_of_words <= 2:
        # corner cases:
        # 1) list with empty strings
        # 2) list with one non-empty string
        # 3) list with two non-empty strings
        joiner = " and " if number_of_words == 2 else ""
        return joiner.join(words)
    
    return ", ".join(words[:-1]) + " and " + words[-1]

def format_words(words):
    words = [w for w in words if w] if words else ''
    if not words:
        return ''
    return '{seq} and {last}'.format(seq=', '.join(words[:-1]), last=words[-1]) if len(words) !=1 else '{0}'.format(words[0])

def format_words(words):
    return " and ".join(", ".join(filter(bool, words or [])).rsplit(", ", 1))

from itertools import chain

def format_words(words):
    if not words: return ''
    
    filtered = [s for s in words if s]
    nCommas  = len(filtered)-2
    nAnd     = min(1,len(filtered)-1)
    chunks   = [', '] * nCommas + [' and '] * nAnd + ['']
    
    return ''.join(chain(*zip(filtered, chunks)))

def format_words(words):
    if not words or words == ['']:
        return ''
    words = [i for i in words if i != '']
    if len(words) == 1:
        return words[0]
    return ', '.join(words[:-1]) + ' and ' + words[-1]

def format_words(w=None):
    return ', '.join(filter(lambda _:bool(_),w))[::-1].replace(',','dna ',1)[::-1] if w else ''

def format_words(words):
    return ', '.join([word for word in words if word] if words else [])[::-1].replace(' ,', ' dna ', 1)[::-1]

def format_words(words):
    if words!=[""] and words!=[] and words is not None:
        l=[word for word in words if word!='']
        return ", ".join(l[:-1])+' and '+l[-1:][0] if len(l)>1 else l[0]
    return ''


def format_words(words):
    words = [w for w in words if w] if words else ''
    if not words:
        return ''
    return f'{", ".join(words[:-1])} and {words[-1]}' if len(words) !=1 else words[-1]