A function to see if one list is a shallow copy of other

Assignment Help Computer Engineering
Reference no: EM132942

Question

Modify this function to check to see if one list is a shallow copy of 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

Reference no: EM132942

Questions Cloud

Display the miles per gallon obtained for each tankful : Display the miles per gallon obtained for each tankful
What do you understand by the term branding : What do you understand by the term branding The organisational brand defines how the organization best meets its customers' needs in unique and compelling ways. Discuss the statement with reference to relevant brand indentities
What is bobs private key : What is Bob's private key?
Computation of basic eps for the year 2002 : What number of shares can be used in the computation of basic EPS for the year 2002?
A function to see if one list is a shallow copy of other : A function to see if one list is a shallow copy of other
Evaluate the amount of taxes paid in country : Evaluate the amount of taxes paid in Country
Arrays and control structures important tools in programming : Arrays and control structures important tools in programming.
Make entries in the journals of the capital projects fund : Make the appropriate entries in the general journals of the Capital Projects Fund
Create an xml document containing information : Create an XML document containing information.

Reviews

Write a Review

 

Computer Engineering Questions & Answers

  What personnel implications are when setting up a wan

What personnel implications are when setting up a wan? You are hired by a firm that has offices in Peru, France, the United States, and Hungary. Your job is to coordinate a team of IT workers to connect all of individual sites into one large WAN.

  Illustrate decryption equation

Illustrate decryption equation.

  What is green computing and green communication technology

What is Green Computing and Green Communication technology.

  Modify compound interest program

Modify compound interest program

  Write a research report on design of a cisco router

Systems research and investigate novel ideas and applications.

  What do you mean by pseudocode and case subroutine call

What do you mean by pseudocode and case Subroutine call

  Write pseudo code - program and draw flow chart

Write pseudo code, program and draw flow chart for programs

  Convert csv file into html file

Convert CSV file into HTML file

  Data representation and logic

Representing Text and Numbers, Binary Arithmetic, Interpreting Logical Statements, Logic Puzzle, Binary and Algorithms.

  Is it right that rbac functionality is complicated

Is it right that RBAC functionality is complicated

  How to run and modify marie program

How to run and modify marie program Include a decision before storing and outputing result. If  value of the result is not positive (so zero or negative), set  Result value to the value ZERO (0)

  Write down an account class

Write down an Account Class.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd