Write Python code using a double while loop that takes a string and a substring
ID: 3705995 • Letter: W
Question
Write Python code using a double while loop that takes a string and a substring from the user, and removes all instances of the substring, returning that new resultant string.
You may not use any built-in functions/methods besides len() and .append(). Specifically, you may NOT use the replace() method.
def remove(s1, s2):
string = s1
sub = s2
#YOUR CODE GOES HERE (indented)
return ""
#END YOUR CODE
Write Python code using a double while loop that takes a string and a substring from the user, and removes all instances of the substring, returning that new resultant string.
You may not use any built-in functions/methods besides len() and .append(). Specifically, you may NOT use the replace() method.
def remove(s1, s2):
string = s1
sub = s2
#YOUR CODE GOES HERE (indented)
return ""
#END YOUR CODE
Explanation / Answer
def remove(s1, s2): string = s1 sub = s2 i = 0 result = '' while iRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.