def  list_to_str(lis):
        '''Return  the  same  output  as  str(lis)  of  a  list  of  integers  lis  
        Arguments:
        lis  --  a  list
        '''
        s  =  '['  #start  with  '['  and  build  up  a  solution
                   #from  there
        
        for  i  in  range(len(lis)  -  1):    #Don't  include  i  = len(lis)-1 because
                                              #we  need  ']'  and  not  ',  '  after  it
                s  +=  (str(lis[i])  +  ',  ')    
        s  +=  (lis[-1]  +  ']')
        return  s  



                
def  lists_are_the_same(list1,  list2):
        '''Return  True  iff  list1  and  list2  have  the  same  elements  in  the  same  order

        Arguments:
        list1,  list2  --  lists
        
        '''
        if  len(list1)  !=  len(list2):      #Take  care  of  the  easy  case  first
                return  False
        
        i  =  0
        while  i  <  len(list1):
                if  list1[i]  !=  list2[i]:
                        return  False                    #If  even  one  pair  differs,  we  can  return
                                                         #False  right  away
                i  +=  1
        
        return  True                                      #Checked  all  the  pairs,  didn't  return  False
                                                          #so  therefore  must  return  True
                                                          #From  the  last  lab
def  lists_are_the_same(list1,  list2):
    '''Return  True  iff  list1  and  list2  have  the  same  elements  in  the  same  order

      Arguments:
      list1,  list2  --  lists
     
    '''
    if  len(list1)  !=  len(list2):  #Take  care  of  the  easy  case  first
        return  False
       
    i  =  0
    while  i  <  len(list1):
            if  list1[i]  !=  list2[i]:
                return  False  # If  even  one  pair  differs,  we  can  return
                             # False  right  away
            i  +=  1
    return  True # Checked  all  the  pairs,  didn't  return  False
                #so  therefore  must  return  True

################################################################################
def  list1_starts_with_list2(list1,  list2):
    '''Return  True  iff  the  first  len(list2)  elements  of  list1  are  the  same, 
      and  are  in  the  same  order  as,  list2
     
    Arguments:
    list1,  list2  --  lists
    '''
    #Almost  the  same  idea  as  in  lists_are_the_same
    if  len(list1)  <  len(list2):
        return  False
    i  =  0
    while  i  <  len(list2):
        if  list1[i]  !=  list2[i]:
            return  False

        i  +=  1
    return  True



def  list1_starts_with_list2_noloops(list1,  list2):
    '''Return  True  iff  the  first  len(list2)  elements  of  list1  are  the  same, 
    and  are  in  the  same  order  as,  list2
     
    Arguments:
    list1,  list2  --  lists
    '''

    return  list1[:len(list2)]  ==  list2

#Note:  we  didn't  have  to  check  the  whether   list1  is  longer  than
#list2,  since  list1[:len(list2)]  happens  to  work  even  for  large
#len(list2)  (if  n  >  len(list1),  list1[:n]  is  simply  list1[:]
#Longer  (and  worse)  version  that  does  the  same  thing:
#if  list1[:len(list2)]  ==  list2
#   return  True
#else:
#   return  False

################################################################################

def  match_pattern(list1,  list2):
    '''Return  True  iff  list2  appears  as  a  sublist  of  list1
     
    Arguments:
    list1,  list2  --  lists
    '''
    # Same  idea  as  above
    # Note:  len(n)  for  n  <  1  is  just  [],  so  we  don't  need  to  explicitly  consider
    #the  case  that  len(list2)  >  len(list1)
    for  i  in  range(len(list1)-len(list2)+1):
        if  list1[i:(i+len(list2))]  ==  list2:
            return  True

    return  False

################################################################################
def  duplicates(list1):
    '''Return  True  iff  list1  has  two  equal  adjacent  elements
    Arguments:
    list1  --  a  list
    '''

    for  i  in  range(len(list1)-1):
        if  list1[i]  ==  list1[i+1]:
            return  True

    return  False
