Question: Write a python program that prints the same result as str.strip(characters). For this program, any string function cannot be used, such as str.strip(), str.lstrip(), str.rstrip(),
Write a python program that prints the same result as str.strip(characters).
For this program, any string function cannot be used, such as str.strip(), str.lstrip(), str.rstrip(), etc.
# The `string` and `characters` variable may be changed to a different value # when your program is tested by the grader. string = ",-* banana !-,*" characters = ",-*! " # write your code stripped_string = # Check you code works the same way with the strip() method. # Will print True if it is. print(stripped_string == string.strip(characters))
Examples:
- If the `string` is ",-*banana !-,*" and `characters` is ",-*! ", the expected `stripped_string` is "banana"
- If the `string` is ",-*ban!-ana !-,*" and `characters` is ",-*! ", the expected `stripped_string` is "ban!-ana"
- If the `string` is ",-*ban!-ana !-,*" and `characters` is ",-*!", the expected `stripped_string` is "ban!-ana "
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
