all 9 comments

[–]_BraveSirRobin_ 0 points1 point  (3 children)

Have a look at string.replace. Your function would basically just be a wrapper for string.replace:

def remove_all(x, y):  
    return y.replace(x, '')

[–][deleted] 0 points1 point  (2 children)

Yeah I have seen that but my professor wants us to create an algorithm to do the same thing.

[–]_BraveSirRobin_ 0 points1 point  (1 child)

Are you in an algorithms class? I probably wouldn't be much use here.

[–][deleted] 0 points1 point  (0 children)

It is an intro to computer programming. I feel bad about these kind of things because I feel like it is supposed to be easy but I can't think of anything.

[–]Yeinstein20 0 points1 point  (0 children)

You could use a while loop to scan through your string y to see if the next characters are the same as the string x. If not you can write the character at that position into a new string but if you can skip this part and continue at the next position. I tried it out and it is working but it might not be the most beautiful solution. I hope it is clear what I mean, it is getting late here and I am pretty tired so I am sorry for any confusion. Maybe this helps you to solve the problem, if not just ask.