Function to check to see if one list is a shallow copy


Modify this function to check to see if one list is a shallow copy of the other.

def first_mismatch(lst1, lst2):
'''(list of objects, list of objects) -> int

Return the index of the first item at which the values of lst1 and lst2
differ. Return -1 if no differences are found.

>>> first_mismatch(['a', 'b', 'c'], ['a', 'd', 'c'])
1
>>> first_mismatch(['a', 'b', 'c'], ['a', 'b', 'c', 'd'])
3
>>> first_mismatch(['a', 'b', [1]], ['a', 'b', [1]])
-1
'''

shorter = min(len(lst1), len(lst2))
for idx in range(shorter):
if lst1[idx] != lst2[idx]:
return idx

if len(lst1) == len(lst2):
return -1

return shorter  

Request for Solution File

Ask an Expert for Answer!!
Programming Languages: Function to check to see if one list is a shallow copy
Reference No:- TGS090561

Expected delivery within 24 Hours