All of the animals are having a feast! Each animal is bringing one dish. There is just one rule: the dish must start and end with the same letters as the animal's name. For example, the great blue heron is bringing garlic naan and the chickadee is bringing chocolate cake.

Write a function `feast` that takes the animal's name and dish as arguments and returns true or false to indicate whether the beast is allowed to bring the dish to the feast.

Assume that `beast` and `dish` are always lowercase strings, and that each has at least two letters. `beast` and `dish` may contain hyphens and spaces, but these will not appear at the beginning or end of the string. They will not contain numerals.

Difficulty: introductory

Starter code:

def feast(beast, dish):
	

Solutions:
def feast(beast, dish):
    return beast[0]==dish[0] and dish[-1]==beast[-1]

def feast(beast, dish):
    return beast[0] == dish[0] and beast[-1] == dish[-1]    

def feast(beast, dish):
    return beast.startswith(dish[0]) and beast.endswith(dish[-1])

def feast(beast, dish):
    """ (str, str) -> bool
    Return true if dish and beast start and end with same letters.
    """
    return beast[0] == dish[0] and beast[-1] == dish[-1]

def feast(beast, dish):
    return True if beast[:1] == dish[:1] and beast[-1] == dish [-1] else False

def feast(beast, dish):
    if beast[0] == dish[0] and beast[-1] == dish[-1]:
        return True
    else:
        return False

def feast(b, d):
    return b[::len(b)-1] == d[::len(d)-1]

feast = lambda beast, dish: beast[0].lower()==dish[0].lower() and beast[-1].lower()==dish[-1].lower()

feast = lambda beast, dish: beast[0] == dish[0] and beast[-1] == dish[-1]

feast = lambda beast, dish: all([beast[i] == dish[i] for i in [0,-1]])

feast = lambda b, d: (b[0], b[-1]) == (d[0], d[-1])

def feast(beast, dish):    
    return [beast[0], beast[-1]] == [dish[0], dish[-1]]
    


def feast(beast, dish):
    # your code here
    pass
    b = beast.replace(" ","")
    length_b = len(b)
    
    d = dish.replace(" ","")
    length_d = len(d)
    
    new_b = b[0] + b[-1]
    new_d = d[0] + d[-1]
    
    return new_b == new_d

def feast(beast, dish):
    return beast[0] + beast[-1] == dish[0] + dish[-1]

def feast(beast: str, dish: str) -> bool:
    """Return true if dish and beast start and end with same letters."""
    return beast[0] == dish[0] and beast[-1] == dish[-1]

def feast(beast, dish):
  dish_valid = (beast[0], beast[-1]) == (dish[0], dish[-1])
  return dish_valid


def feast(beast, dish):
    return beast.endswith(dish[-1]) and beast.startswith(dish[0])

def feast(beast, dish):
    return True if (beast[0], beast[-1]) == (dish[0], dish[-1]) else False
    pass

def feast(beast, dish):
    return True if beast[0]==dish[0] and beast[::-1][0]==dish[::-1][0] else False

def feast(beast, dish):
    """ (str, str) -> bool
    Return true if beast and dish start and end with same char.
    """
    return beast[0] == dish[0] and beast[-1] == dish[-1] 

def feast(beast, dish):
    if beast[0] == dish[0] and beast[-1] == dish[-1]:
        return True
    return False

def feast(b, d):
    return b[0]+b[-1] == d[0]+d[-1]

def feast(beast, dish):
    return beast[::len(beast)-1] == dish[::len(dish)-1]

import re

def feast(beast, dish):
    return re.sub(r'\B(.*)\B', '', beast) == re.sub(r'\B(.*)\B', '', dish)

feast = lambda a,b : 2==(lambda a,b,z,j : (lambda f, arg : sum([f(*a) for a in arg]))((lambda a,b : a==b),[[a[j],b[j]],[a[z],b[z]]]))(a,b,(lambda: 777).__code__.co_nlocals,-(lambda _: 777).__code__.co_nlocals)

def feast(beast, dish):    # your code here
    
    
    return dish.startswith(beast[0]) and dish.endswith(beast[-1])

def feast(beast, dish):
    print(beast[1])
    print(beast[-1])
    print(dish[1])
    print(dish[-1])
    if beast[0] == dish[0] and beast[-1] == dish[-1]:
        return True
    else:
        return False

def feast(beast, dish):
    x = beast[0] + beast[len(beast)-1]
    y = dish[0] + dish[len(dish)-1]
    if x == y:
        return True
    else:
        return False


def feast(beast, dish):
    return (dish.startswith(beast[0]) and dish.endswith(beast[len(beast)-1]))

feast = lambda beast, dish: beast[-1::1-len(beast)] == dish[-1::1-len(dish)]

feast=lambda b,d:b[0]==d[0] and b[-1]==d[-1]

feast=lambda s,d:(s[0],s[-1])==(d[0],d[-1])

def feast(b,d):
    return b[0]==d[0] and b[-1]==d[-1]

def feast(beast, dish):
    a = beast[0]
    b = beast[len(beast)-1]
    c = dish[0]
    d = dish[len(dish)-1]
    if a.lower() == c.lower() and b.lower() == d.lower():
        return True
    else:
        return False


def feast(beast, dish):
    return beast[0:1] == dish[0:1] and beast[::-1][0:1] == dish[::-1][0:1]

def feast(beast, dish):
    print(beast, dish)
    return beast[-1] == dish[-1] and beast[0] == dish[0]

def feast(beast, dish):
    return beast.startswith(dish[:1]) & beast.endswith(dish[-1])

def feast(beast, dish):
    return True if beast[::len(beast)-1] == dish[::len(dish)-1] else False

def feast(beast, dish):
    res = False
    return beast[0] == dish[0] and beast[len(beast)-1] == dish[len(dish)-1]

def feast(beast, dish):
    print(beast, dish)
    return beast[0] + beast[-1] == dish[0]+dish[-1]

def feast(beast, dish):
    return beast and dish and beast[0] == dish[0] and beast[-1] == dish[-1]

def feast(b, d):
    return d[0] == b[0] and d[-1] == b[-1]

def feast(beast, dish):
    if beast[0] == dish[0] and beast[-1] == dish[-1]: return True
    else: return False
    
    
# All of the animals are having a feast! Each animal is bringing one dish.
# There is just one rule: the dish must start and end with the same letters 
# as the animal's name. For example, the great blue heron is bringing garlic
# naan and the chickadee is bringing chocolate cake.



def feast(beast, dish):
    return ''.join(beast.split())[0]==''.join(dish.split())[0] and ''.join(beast.split())[-1]==''.join(dish.split())[-1]

def feast(beast, dish):
    for char in beast:
        if beast[0] == dish[0] and beast[-1] == dish[-1]:
            return True
        else:
            return False

def feast(beast, dish):
    a = beast[0] + beast[-1]
    b = dish[0] + dish[-1]
    return a == b

def feast(beast, dish):
    # your code here
    return (beast[0:1] == dish[0:1] and beast[-1:-2:-1] == dish[-1:-2:-1])

def feast(beast, dish):
    bf, bl = beast[0], beast[-1]
    df, dl = dish[0], dish[-1]
    return (bf, bl) == (df, dl)

def feast(beast, dish):
       return dish[0] == beast[0] and beast[-1] == dish[-1]



def feast(beast, dish):
    beastList = list(beast)
    dishList = list(dish)
    if beastList[0] == dishList[0] and beastList[-1] == dishList[-1]: 
        return True
    else: 
        return False

def feast(beast, dish):
    x = "".join(c for c in beast.split(" "))
    y = "".join(c for c in dish.split(" "))
    return (y[0] == x[0] and y[-1] == x[-1])


def feast(beast, dish):
    return True if beast[0] == dish [0] and beast[-1] == dish[-1] else False



feast("brown bear","bear claw" )

def feast(beast, dish):
    return all(beast[i]==dish[i] for i in (-1,0))

def feast(beast, dish):
    if dish[len(dish)-1] != beast[len(beast)-1] and beast[0] != dish[0]:
        return False
    if dish[len(dish)-1] == beast[len(beast)-1] and beast[0] == dish[0]:
        return True
    else:
        return False

def feast(beast: str, dish: str) -> bool:
    return True if dish.startswith(beast[0]) and dish.endswith(beast[-1]) else False

def feast(beast, dish):
    first = beast[0]
    last = beast[-1]
    first1 = dish[0]
    last1 = dish[-1]
    if first == first1 and last == last1:
        return True
    else:
        return False

def feast(beast, dish):
    beast
    if beast[0] == dish[0] and beast[-1] == dish[-1]:
        return True
    else:
        return False

def feast(beast, dish):
    if beast[0] == dish[0] and beast[-1] == dish[-1]:
        return True
    elif beast[0] != dish[0] or beast[-1] != dish[-1]:
        return False

def feast(beast, dish):
    
    beast.replace(' ','')
    beast_ls = [x for x in beast]
    
    dish.replace(' ','')
    dish_ls = [x for x in dish]
    
    if beast_ls[0] == dish_ls[0] and beast_ls[-1] == dish_ls[-1]:
        return True
    else:
        return False


def feast(beast, dish):
    x=len(beast)
    y=len(dish)
    if (dish[0]==beast[0])and(beast[x-1]==dish[y-1]):
        return True
    else:
        return False
    # your code here
    pass

def feast(beast, dish):
    firstletter = beast[0]
    lastletter = beast[-1]
    firstletterdish = dish[0]
    lastletterdish = dish[-1]
    return (firstletter,lastletter) == (firstletterdish,lastletterdish)

def feast(b, d):
    return [b[0] == d[0], b[-1] == d[-1]] == [True, True]

def feast(beast, dish):
    animalbegin=beast[0]
    animalend=beast[len(beast)-1]
    dishbegin=dish[0]
    dishend=dish[len(dish)-1]
    if animalbegin==dishbegin and animalend==dishend:
        return True
    return False

def feast(b, d):
    result = False
    if d[0] == b[0] and d[-1] == b[-1]:
        result = True
    return result

def feast(beast, dish):
    return True if dish[0] == beast[0] and dish[len(dish) - 1] == beast[len(beast) -1] else False

def feast(beast, dish):
    return True if (beast.split()[0][0] == dish.split()[0][0]) and (beast.split()[-1][-1] == dish.split()[-1][-1]) else False


def feast(beast, dish):
    dish_allowed = (beast[0] == dish[0]) and (beast[-1] == dish[-1])
    return dish_allowed

def feast(beast, dish):
    # your code here
    return beast.startswith(dish[0]) and beast.endswith(dish[-1])
    # don't have to put True or False, as if they will return means its true


def feast(beast, dish):
    # your code here
    if str(beast[0]) == str(dish[0]) and beast[-1] == dish[-1]:
        return True
    else:
        return False

def feast(beast, dish):
    b_list = list(beast)
    d_list = list(dish)
    if b_list[0] == d_list[0] and b_list[-1] == d_list[-1]:
        return True
    else:
        return False

def feast(beast, dish):
    fbeast, lbeast = beast[0], beast[-1]
    fdish, ldish = dish[0], dish[-1]

    return fbeast == fdish and lbeast == ldish

def feast(beast, dish):
    print(beast, dish)
    return True if beast[-1] == dish[-1] and beast[0] == dish[0]else False

def feast(beast, dish):
    # your code here
    print((beast+'*','-',dish+'*'))
    if beast[0] == dish[0]:
      if beast[-1] == dish[-1]:
          return True
      else:
          return False
      
    else:
        return False


def feast(beast, dish):
    print(beast,dish)
    if beast[0]==dish[0] and beast[-1]==dish[-1]:
        return True
    else:
        return False
    # your code here
    pass

def feast(beast, dish):
  for i in beast:
      if beast[0] == dish[0]:
          if beast[-1] == dish[-1]:
              return True
          else:
              return False
      else:
          return False
          
          


def feast(beast, dish):
    lower1= beast.lower()
    lower2= dish.lower()
    list1 = lower1[0]
    list2 = lower2[0]
    list3 = lower1[-1]
    list4 = lower2[-1]
    if list1 == list2 and list3 == list4:
        return True
    else:
        return False

def feast(beast, dish):
  if beast[0] == dish[0] and beast[-1] == dish[-1]:
      return True
  else:
      return False


 #lengthf = len(first)
 #   lengths = len(second)
 #   if second in first[-lengths:]:
 #       return True
  #  else:
  #      return False


#input - two strings
#ouput - boolean
#edge cases - empty string?, all lower case letters, hyphens and spaces are allowed but not at beginning or end of string
#assumptions/end goal - this function needs to return true if first and last letters of beast are same as dish. Return false if not.

#sample data
#("great blue heron", "garlic naan") = True
#("chick-a-dee", "chocolate cake") = True
#("chickadee", "chocolate croissant") = False
#("german*8shephard", "gluten snack") = False


#function feast takes two arguments, beast & dish
def feast(beast, dish):
#heck if the first letter and last letters are the same and return True if they are
   return beast[0] == dish[0] and beast[-1] == dish[-1]


def feast(beast, dish):
    if (beast and dish) != "":
        if beast[0] == dish[0] and beast[-1] == dish[-1]:
            return True
        else:
            return False
    else:
        return False

feast = lambda beast,dish: beast.startswith(dish[0]) and beast.endswith(dish[-1])

feast = lambda beast, dish: dish.startswith(beast[0]) and dish.endswith(beast[-1])

def feast(beast, dish):
    f, s=beast[0], beast[-1]
    return dish[0]==f and dish[-1]==s

def feast(beast, dish):
    
 
    # your code here
    x = beast[0]
    y = dish[0]
    z = beast[-1]
    k = dish[-1]
    if (x == y) and (z == k):
        return True
    else:
        return False


def feast(beast, dish):
    #if beast[0]==dish[0] and beast[-1]==dish[-1]:
    #    return True
    #else:
    #    return False
    #return  beast[0]==dish[0] and beast[-1]==dish[-1]
    return beast.startswith(dish[0]) and beast.endswith(dish[-1])

def feast(beast, dish):
    # your code here
    pass
    indexBeast = len(beast)
    indexDish = len(dish)
    beast1 = beast[0]
    beastLast = beast[indexBeast-1]
    dish1 = dish[0]
    dishLast = dish[indexDish-1]
    
    if beast1 == dish1 and beastLast == dishLast:
        return True
    else :
        return False

def feast(beast, dish):
    bfirst = beast[0]
    blast = beast[-1]
    dfirst = dish[0]
    dlast = dish[-1]
    if bfirst == dfirst and blast == dlast:
        return(True)
    else:
        return(False)

def feast(beast, dish):
    # your code here
    
    if beast[-1].lower() == dish[-1].lower() and beast[0].lower() == dish[0].lower() :
        return True
    else:
        return False


def feast(beast, dish):
    beast = beast.lower()
    dish = dish.lower()
    return beast[0] == dish[0] and beast[-1] == dish[-1]

def feast(beast, dish):
    # if beast[0] == dish[0] and beast[last index] == dish[last index] return True 
    return beast[0] == dish[0] and beast[-1] == dish[-1]


def feast(beast, dish):
    start = beast.startswith(dish[0])
    finish = beast.endswith(dish[-1:])
    
    if start and finish:
        return True
    return False

def feast(b, d):
    x = [b[0] , b[len(b)-1]]
    y = [d[0] , d[len(d)-1]]
    return x==y


def feast(beast, dish):
    start = beast.startswith(dish[:1])
    end = beast.endswith(dish[-1:])
    return start and end


def feast(beast, dish):
    beast = beast.lower()
    dish = dish.lower()
    if beast[-1] == dish[-1] and beast[0] == dish[0]:
           return True
    else:
           return False
           
feast("Faris","Mangos")

def feast(beast, dish):
    is_valid = True
    if beast[0] == dish[0] and beast[len(beast) - 1] == dish[len(dish) - 1]:
        is_valid = True
        return is_valid
    else:
        is_valid = False
        return is_valid


def feast(beast, dish):
    a = beast[0]
    b = beast[-1]
    c = dish[0]
    d = dish[-1]
    if a == c:
        if b == d:
            return True
        else:
            return False    
    elif a != c:
        return False

import unittest


def feast(beast, dish):
    return True if beast[0] == dish[0] and beast[-1] == dish[-1] else False
    
    
class TestFeast(unittest.TestCase):
    def test_should_return_false_when_given_first_char_and_end_char_of_beast_name_is_not_same_with_dish(self):
        beast, dish = "brown bear", "bear claw"
        actual = feast(beast, dish)
        self.assertEqual(actual, False)

    def test_should_return_true_when_given_first_char_and_end_char_of_beast_name_is_same_with_dish(self):
        beast, dish = "great blue heron", "garlic naan"
        actual = feast(beast, dish)
        self.assertEqual(actual, True)


def feast(beast, dish):
    a=len(dish)-1
    if beast[0]==dish[0] and beast[len(beast)-1]==dish[a]: 
         return True
    else:
        return False

def feast(beast, dish):
    print(beast, dish)
    # your code here
    return dish.startswith(beast[0]) and dish.endswith(beast[-1])

def feast(beast, dish):
    
    l1 = len(beast) - 1
    l2 = len(dish) - 1
    
    
    return beast[0] == dish[0] and beast[l1] == dish[l2]

def feast(beast, dish):
    if beast[-1] == dish[-1] and beast[0] == dish[0]:
        return True
    return False