Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PYTHON 2. Write a function matches that accepts two strings as arguments. The function then returns the number of times that the two strings have

PYTHON

2. Write a function matches that accepts two strings as arguments. The function then returns the number of times that the two strings have the same character in the same location, ignoring case. For example, in the first example below, the number of matches is 3 because the two strings agree for all characters accept for the characters at index 1. Hints: 1) use indexed iteration to iterate over both strings simultaneously, 2) Q: what should you do if the strings have different lengths? A: ignore the extra characters of the longer string.

>>> matches( 'hare','here')

3

>>> matches( 'pear','Plum' )

1

>>> matches( 'able', 'Abel' )

1

>>> matches( 'art', 'ARTSY' )

3

>>> matches( 'artsy', 'ART' )

3

>>> matches( 'hello!', 'good bye!')

0

>>> matches( 'Mississippi', 'Missouri' )

5

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Expert Oracle9i Database Administration

Authors: Sam R. Alapati

1st Edition

1590590228, 978-1590590225

More Books

Students also viewed these Databases questions