Some new animals have arrived at the zoo. The zoo keeper is concerned that perhaps the animals do not have the right tails. To help her, you must correct the broken function to make sure that the second argument (tail), is the same as the last letter of the first argument (body) - otherwise the tail wouldn't fit!

If the tail is right return true, else return false.

The arguments will always be strings, and normal letters.

Difficulty: introductory

Starter code:

def correct_tail(body, tail):
	

Solutions:
def correct_tail(body, tail):
    return body.endswith(tail)


def correct_tail(body, tail):
    return body[-1] == tail

def correct_tail(body, tail):
    sub = body[len(body)-len(tail)]
    if sub == tail:
        return True
    else:
        return False

correct_tail = str.endswith

def correct_tail(body, tail):
    return True if body[-1]==tail else False

def correct_tail(body, tail):
    return body[-1:] == tail

def correct_tail(body, tail):    
    return True if body[len(body)-1:] == tail else False

def correct_tail(body, tail):
    #sub = body.endswi(-1)
    return body.endswith(tail)


def correct_tail(b, t):return b[-1:]==t

correct_tail = lambda a,t: a[-1]==t

correct_tail=lambda b,t: b[-1]==t

correct_tail = lambda a, b: a[-1] == b

def correct_tail(body, tail):
     return (tail == body[-1:])


def correct_tail(body: str, tail: str) -> bool:
    """ Check if the tail is the same as the last letter of the first argument body. """
    return body[-1] == tail

def correct_tail(body, tail):
    b = body[-1:].lower() 
    c = tail[0].lower()
    if b == c:
        return True
    else: 
        return False
correct_tail("Fox", "x")

correct_tail = lambda body, tail: body[-1] == tail[0]

def correct_tail(body, tail):
    n = len(body)
    if body[n-1] == tail[0]:
        return True
    else:
        return False


def correct_tail(body, tail):
#      sub = body.substr(len(body)-len(tail.length)
    return True if body[-1] == tail else False


def correct_tail(body, tail):
    x = body.split()
    y = body[-1]
    if y == tail:
        return True
    else:
        return False

def correct_tail(body, tail):
    return body[:-2:-1] == tail
#      sub = body.substr(len(body)-len(tail.length)
#         if sub = tai:
#     return True
#         else:
#     return False


def correct_tail(body, tail):
    x = len(body)-1
    if tail == body[x]:
        return True
    else:
        return False

def correct_tail(body, tail):
    ch = body[-1]
    return ch == tail


def correct_tail(body, tail):
    i=len(body)-len(tail)
    if body[i]==tail:
        return True 
    else:
        return False

def correct_tail(body, tail):
    a = body[-1]
    if a == tail:
        return True
    else:
        return False

def correct_tail(b, t):
    return b[::-1][0] == t

def correct_tail(body, tail):
    sub = len(body)
    sub =(body[::-sub])
    if sub == tail:
        return True
    else:
        return False


def correct_tail(body, tail):
    for i in body: 
        if tail == body[-1]:
            return True
        else:    
            return False

def correct_tail(body, tail):
    sub = body[-1]
    sub = str(sub)
    if sub == tail:
        return True
    else:
        return False

correct_tail=lambda b, t: t==b[-1]

def correct_tail(body, tail):
    # calculate the index of the last letter from the string
    index = len(body) - 1
    #assign the last letter of the string to the variable
    last_letter = body[index]
    #compare the last letter of the string with the tail
    if (last_letter == tail):
        return True
    else:
        return False

import unittest


def correct_tail(body, tail):
    last_char_of_body = body[-1]
    return True if last_char_of_body == tail else False


class TestCorrectTail(unittest.TestCase):
    def test_should_return_false_when_last_of_char_of_body_is_not_equal_tail(self):
        self.assertFalse(correct_tail(body="Emu", tail="m"))

    def test_should_return_true_when_last_of_char_of_body_is_equal_tail(self):
        self.assertTrue(correct_tail(body="Fox", tail="x"))


def correct_tail(body, tail):
    return True if body[len(body)-len(tail):len(body)] == tail else False

def correct_tail(body, tail):
    sub = body[-1]
     
    if sub == tail :
        result =  True
    else :
        result = False
    return result

def correct_tail(body, tail):
    n=len(body)
    if body[n-1]==tail:
        return True
    else:
        return False

def correct_tail(b,t):
    if t==b[len(b)-1]:
       return True
    else:
        return False

def correct_tail(body, tail):
    #sub = body.substr(len(body)-len(tail.length)
    if body.endswith(tail):
        return True
    else:
        return False

def correct_tail(body, tail):
    for char in body:
        if body[-1] == tail:
            return True
            
        else:
            return False

def correct_tail(body, tail):
     return body[len(body) - 1] == tail

def correct_tail(body, tail):
    if isinstance(body, str) and isinstance(tail, str) and len(tail) > 0:
        if body[-1] == tail:
            return True
    return False

def correct_tail(body, tail):
     return body.endswith(tail[0])

def correct_tail(body, tail):
     return list(body).pop() == tail

def correct_tail(body, tail):
    sub = body[-1].lower()
    return True if sub == tail else False


def correct_tail(body, tail):
    li=list(body)
    if li[-1]==tail:
        return True
    else:
        return False


def correct_tail(body, tail):
     return body[-1] == tail
#      return body.endswith(tail)


correct_tail = lambda b, t: b[-1:] is t or b is t

def correct_tail(body, tail):
    sub = len(body) - len(tail)
    if body[-1] == tail:
        return True
    else:
        return False

def correct_tail(body, tail):
    sub = body[len(body)-1]
    if sub == tail[len(tail)-1]:
        return True
    else:
        return False

def correct_tail(body, tail):
    end = body[-1]
    return tail == end

correct_tail = lambda body, tail: body[-1:] == tail


def correct_tail(body, tail):
    if tail == body[len(body)-1:]:
        return True
    else:
        return False

def correct_tail(body, tail):
    last = body[-1]
    if tail == last:
        return True
    else:
        return False

def correct_tail(body, tail):
    total = len(body)
    last_n = total - 1
    last = body[last_n]
    if last == tail:
        return True
    else:
        return False

def correct_tail(body, tail):
        if body[-1] == tail:
            return True
        return False
    
#      sub = body.substr(len(body)-len(tail.length)
#         if sub = tai:
#     return True
#         else:
#     return False


def correct_tail(body, tail):
    sub = body[len(body)-1:body.rfind(tail)+1]
    if tail == sub:
        return True
    else:
        return False

def correct_tail(body, tail):
    subs = body[len(body)-len(tail)]
    if subs == tail:
        return True
    else:
        return False

correct_tail=lambda b,t:b[-1:]==t

def correct_tail(body, tail):
    bool=False
    last=len(body)
    last=last-1
    if body[last]==tail:
        bool=True
    return bool


def correct_tail(body, tail):
    sub = body[-1] 
    if sub == tail:
        return True
    else:
        return False
print(correct_tail("Fox", "x"))

def correct_tail(body, tail):
  sub = body[-1]
  if sub == tail:
      return True
  else:
      return False

print(correct_tail('fox','x'))

def correct_tail(body, tail):
    #sub = body.substr(len(body)-len(tail.length)
    #if sub == tail:
    #    return True
    #else:
    #    return False
    return body.endswith(tail)

def correct_tail(body, tail):
    bodytail = body[-1]
    if bodytail == tail:
        return True
    else:
        return False

def correct_tail(body, tail):
    #sub = body.substr(len(body)-len(tail.length))
    sub = body[len(body) -1 ]
    if sub == tail:
        return True
    else:
        return False

def correct_tail(body, tail):
    sub = body[-1]
    if sub == tail[-1]:
        return True
    else:
        return False

def correct_tail(body, tail):
     return body[-1] == tail if body else False

def correct_tail(body, tail):
#      sub = body.substr(len(body)-len(tail.length)
    if body.lower()[-1]==tail:
        return True
    else:
        return False

def correct_tail(body, tail):
    animal = []
    for letter in body:
        animal.append(letter)
    if animal[-1] == tail:
        return True
    else:
        return False

def correct_tail(body, tail):
     if body[len(body)-1] is tail:
         return True
     return False

def correct_tail(body, tail):
    sub = body[-1]
    if body[-1] != tail:
        return False
    else:
        return True

def correct_tail(body: str, tail: str):
    return True if body[-1].lower() == tail.lower() else False

def correct_tail(body, tail):
    i = len(body)-2
    sub = body[:i:-1]
    print(sub)
    if sub == tail:
        return True
    else:
        return False

def correct_tail(body, tail):
    body.lower()
    tail.lower()
    a = body[-1]
    if a == tail:
        return True
    else:
        return False

def correct_tail(body, tail):
     if body[-1:] == tail[-1:]: return True
     else: return False    

def correct_tail(body, tail):
    """check that tail is the same as the last letter of the first argument"""
    return body[-1] == tail


def correct_tail(body, tail):
    return 1 if body[-1] == tail else 0

def correct_tail(body, tail):
    list = body.split()
    sub = list[0][-1]
    if sub == tail:
        return True
    else:
        return False

def correct_tail(body, tail):
#     sub = body.substr(len(body)-len(tail.length)
#     if sub == tail:
#         return True
#     else:
#         return False
    
    return tail == body[-1]


import re

def correct_tail(body, tail):
    sub = re.sub(r".", "", body, len(body)-len(tail))
    if sub == tail:
        return True
    else:
        return False

def correct_tail(body, tail):
    b = [str(x) for x in body[::-1]]
    t = [str(y) for y in tail[::-1]]
    
    return True if b[0] == t[0] else False


def correct_tail(body, tail):
    return True if body[len(body) - 1] is tail else False

def correct_tail(body, tail):
  sub = str(body[-1])
  if sub == str(tail):
    return True
  else:
    return False

def correct_tail(body, tail):
    if tail[len(tail)-1] == body[len(body)-1]:
        return(True)
    else:
        return(False)

def correct_tail(body, tail):
    print(body)
    print(tail)
    #b=len(body[-1:])
    #print(b)
    #sub = body.substr(len(body)-len(tail.length)
    if body[-1:] == tail:
        return True
    else:
        return False

def correct_tail(body, tail):
    
     if body.endswith(tail[0]):
         return True
     else:
          return False

correct_tail = lambda body, tail: True if body[-1] == tail else False

def correct_tail(body, tail):
    sub = body[-1]
    if sub is tail:
        return True
    return False

def correct_tail(body, tail):
    return tail is body[-1]

def correct_tail(body, tail):
    sub = body.split()
    if sub[-1][-1] == tail:
        return True
    else:
        return False

def correct_tail(body, tail):
    """
    sub = body[-1]
    if sub == tail:
        return True
    else:
        return False
    """
        
    return body[-1] == tail 

def correct_tail(body, tail):
   #  sub = body.substr(len(body)-len(tail.length)
   #     if sub = tai:
   # return True
   #     else:
   # return False
    bodyList=list(body)
    return bodyList[-1] == tail

def correct_tail(body, tail):
    index = [letter for letter in body]
    if index[-1] == tail:
        return True
    else:
        return False

def correct_tail(body, tail):
    if body == '':
        return False
    return body[-1] == tail


def correct_tail(body, tail):
    sub = body[len(body)-len(tail)]
    return True if (sub==tail) else False

def correct_tail(body, tail):
    let = body[-1]
    if let == tail:
        return True
    else:
        return False

def correct_tail(body, tail):
    sub = len(body)
    last = body[sub - 1]
    if last == tail:
        return True
    else:
        return False

def correct_tail(body, tail):
    if body[-1] is not tail:
        return False
    else:
        return True

def correct_tail(body, tail):
    a = len(body) - 1
    if tail == body[a]:
        return True
    else:
        return False


def correct_tail(body, tail):
    if tail == body[-1::]:
        return True
    else:
        return False

def correct_tail(body, tail):
  body_f = body[-1]
  if body_f == tail:
    return True 
  else:
    return False

def correct_tail(body, tail):
    return True if tail == body[-1::] else False