Question: In Python!!! Write a program that compares two strings given as input. Output the number of characters that match in each string position. The output

In Python!!!
Write a program that compares two strings given as input. Output the number of characters that match in each string position. The output should use the correct verb (match vs matches) according to the character count.
Step 1:
Get the two strings as input (no prompt)
Use an if/else statement to determine which is the shortest string (this is needed for our for loop to ensure we don't get an "out of bounds" error.
Step 2:
Use a for loop and the range of the shortest string to compare each character in the strings to see if they match. Remember, that strings are indexed as 0,1,2, etc. So string[0] gives the first letter. If there is a match, increment the count variable. (We are finding this so we can have the correct verb tense for our output)
Step 3:
Use an if/else statement and the count variable to decide which phrase should be output (match vs. matches). Remember, if there is only one match, it is singular. Otherwise it is plural.
Inputs and Outputs
Ex: If the input is:
crash
crush
the output is:
4 characters match
Ex: If the input is:
cat
catnip
the output is:
3 characters match
Ex: If the input is:
mall
saw
the output is:
1 character matches
Ex: If the input is:
apple
orange
the output is:
0 characters match

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!