Question: Write a method that returns the longest common prefix of two strings. for example, the longest common prefix of distance and disinfection is dis. the

  • Write a method that returns the longest common prefix of two strings. for example, the longest common prefix of distance and disinfection is dis. the header of the method is:def prefix(s1, s2)if the two strings have no common prefix, the method returns an empty string. write a main method that prompts the user to enter two strings and displays their common prefix.

Step by Step Solution

3.46 Rating (149 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Python Code def prefixs1 s2 Function prefix accept two parameters and return a common ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Marketing Questions!