If you like Taco Bell, you will be familiar with their signature doritos locos taco. They're very good.


Why can't everything be a taco? We're going to attempt that here, turning every word we find into the taco bell recipe with each ingredient.


We want to input a word as a string, and return a list representing that word as a taco.

***Key***

all vowels (except 'y') = beef

t = tomato

l = lettuce

c = cheese

g = guacamole

s = salsa

  
***NOTE***    
We do not care about case here. 'S' is therefore equivalent to 's' in our taco.
  
Ignore all other letters; we don't want our taco uneccesarily clustered or else it will be too difficult to eat.

Note that no matter what ingredients are passed, our taco will always have a shell.

Difficulty: introductory

Starter code:

def tacofy(word):
	

Solutions:
import re

TACODICT = {
             't':'tomato', 
             'l':'lettuce',
             'c':'cheese',
             'g':'guacamole',
             's':'salsa'
           }

def tacofy(word):
    return ['shell'] + [TACODICT.get(c, 'beef') for c in re.sub('[^aeioutlcgs]+' ,'', word.lower())] + ['shell']

def tacofy(word):
    tacos = {"a": "beef", "e": "beef", "i": "beef", "o": "beef", "u": "beef", "t": "tomato", "l": "lettuce", "c": "cheese", "g": "guacamole", "s": "salsa"}
    return ["shell"] + [tacos[c.lower()] for c in word if c.lower() in tacos] + ["shell"]


def tacofy(word):
    ingred = {
        'a':'beef', 'u':'beef', 'i':'beef', 'o':'beef', 'e':'beef',
        't':'tomato', 'c':'cheese', 'l':'lettuce', 'g':'guacamole', 's':'salsa'
    }
    return ['shell'] + [ingred[c] for c in word.lower() if c in ingred] + ['shell']

def tacofy(word):
    d = {'t':'tomato', 'l':'lettuce', 'c':'cheese', 'g':'guacamole', 's':'salsa'}
    return ['shell'] + [d.get(i, 'beef') for i in word.lower() if i in 'aeioutlcgs'] + ['shell']

def tacofy(word):
    d = {'a': 'beef', 'e': 'beef', 'i': 'beef', 'o': 'beef', 'u': 'beef', 
         't': 'tomato', 'l': 'lettuce', 'c': 'cheese', 'g': 'guacamole', 's': 'salsa'}
    return ['shell'] + [d[i] for i in word.lower() if i in d] + ['shell']

DCT = {'t': 'tomato', 'l': 'lettuce', 'c': 'cheese', 'g': 'guacamole', 's': 'salsa'}
DCT.update({c:'beef' for c in "aeiuo"})

def tacofy(word):
    return ['shell'] + [DCT[c] for c in word.lower() if c in DCT] + ['shell']

dict = {'a':'beef', 
        'e':'beef',
        'i':'beef', 
        'o':'beef', 
        'u':'beef', 
        't':'tomato', 
        'l':'lettuce', 
        'c':'cheese', 
        'g':'guacamole', 
        's':'salsa'}
        
def tacofy(word):
    # Start with the shell
    outlist = ['shell']
    # Don't forget we're case insensitive!
    for c in word.lower():
        # Is this letter one of the taco ones?  Find its ingredient!
        if c in dict: # Python 3.0 doesn't have dictionary.has_key()
            outlist.append(dict.get(c))
    # Don't forget the final shell wrapper!
    outlist.append('shell')
    return outlist

def tacofy(word):
    word = [i if i.lower() in 'tlcgs' else 'a' if i.lower() in 'aeiou' else '' for i in word ]
    d = {'a': 'beef', 't': 'tomato', 'l': 'lettuce', 'c': 'cheese', 'g': 'guacamole', 's': 'salsa'}
    return ['shell'] + [d[i.lower()] for i in word if i] + ['shell']

ing = {"t": "tomato", "l": "lettuce", "c": "cheese", "g": "guacamole", "s": "salsa", "a": "beef", "|": "shell"}

def tacofy(word):
    return [ing[c] for c in "|{}|".format("".join(c if c in "tlcgs" else "a" if c in "aeiou" else "" for c in word.lower()))]

t=dict(zip('.tlcgsaeiou','shell tomato lettuce cheese guacamole salsa'.split()+['beef']*5))
tacofy=lambda s:[t[c]for c in'.%s.'%s.lower()if c in t]