Tripadvisor Interview Question

You have String 1: "abcdefgh". Write a code to remove "ad" so that you are left with "bcefgh".

Interview Answers

Anonymous

Oct 6, 2014

I feel like he is missing something in the question.

2

Anonymous

Oct 8, 2014

in Python: def remove_substring(string, substring): substring = [s for s in substring] new_string = "" for s in string: if s not in substring: new_string += s return new_string remove_substring("abcdefgh", "ad")

Anonymous

Sep 18, 2014

in python: str = "abcdefgh" print str.strip("abc")