Please code in python Declare a function named contains_char. Its purpose is when given two strings, the first of any length, the second a single character, it will return True if the single character of the second string is found at any index of the first string, and return False otherwise. More specifically, declare your contains_char function such that: It has two parameters (name them descriptively) A string that is being searched through for the second parameter A string that is expected to be a single character in length and is the character being searched for A boolean return type A docstring describing the purpose of the function in your own words Since the caller of this function can be expected to provide the correct arguments, specifically a second argument whose length is one, we will “assert” this assumption in our code such that an error is raised if it is not found to be true. As the first line of code in your function’s body, add the following assert statement and fill in the blank (_____) with your second parameter’s name: assert len(_______) == 1
Please code in python
Declare a function named contains_char. Its purpose is when given two strings, the first of any length, the second a single character, it will return True if the single character of the second string is found at any index of the first string, and return False otherwise. More specifically, declare your contains_char function such that:
- It has two parameters (name them descriptively)
- A string that is being searched through for the second parameter
- A string that is expected to be a single character in length and is the character being searched for
- A boolean return type
- A docstring describing the purpose of the function in your own words
Since the caller of this function can be expected to provide the correct arguments, specifically a second argument whose length is one, we will “assert” this assumption in our code such that an error is raised if it is not found to be true. As the first line of code in your function’s body, add the following assert statement and fill in the blank (_____) with your second parameter’s name:
assert len(_______) == 1
Trending now
This is a popular solution!
Step by step
Solved in 5 steps with 3 images