Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For python 3 Write a function named same_dashes that accepts two strings as parameters and that returns a boolean value indicating whether or not they

For python 3image text in transcribed

Write a function named same_dashes that accepts two strings as parameters and that returns a boolean value indicating whether or not they have dashes in the same places (returning True if they do and False if not). For example, below are four pairs of strings of equal length that have the same pattern of dashes. Notice that the last pair has no dashes at all. string1: "h--there-you." "-15-389 "criminal-plan "abc" string 2: "12(134)-7539" -xy-zzy "(206)555-1384" "9.8 So a call of same_dashes("hi--there-you.", "12--(134)-7539") should return True. By contrast,the call of same_dashes ("hi--there-you", "hey-there-yo-") should return False because the first string has an unmatched dash at index 2 and the second string has an unmatched dash at index 12 To be considered a match, the strings must have exactly the same number of dashes in exactly the same positions. Note that the strings might be of different length, but different-length strings might still return True if it turns out that all of their dashes are in the range of indexes that is within the bounds of the shorter string. For example, the following calls should each return True, because the strings each have two dashes and they are in the same positions. same_dashes("1st-has-more characters", "2nd-has-less") same dashes ("1st-has-less", "2nd-has-more chars") But the following should return False because the longer string has a third dash where the shorter does not same_dashes ("1st-has-more-chars", "2nd-has-less") same_dashes("1st-has-less", "2nd-has-more-characters") Constraints: You should not use any data structures such as arrays to help you solve this problem. But you can declare as many simple variables like int, char, etc. as you like. Declaring auxiliary String variables is also fine. Type your Python solution code here: 1 def same_dashes (str1, str2)

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

Database Processing

Authors: David J. Auer David M. Kroenke

13th Edition

B01366W6DS, 978-0133058352

More Books

Students also viewed these Databases questions

Question

Explain unit, integration, and system testing

Answered: 1 week ago

Question

What is the basis for Security Concerns in Cloud Computing?

Answered: 1 week ago

Question

Describe the three main Cloud Computing Environments.

Answered: 1 week ago