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

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!