Question: This is what I have in my web part `.ascx` file:

```
var _SVR = BellMedia.videoCarousel.videoHub({
    containerDiv: "carousel-<%= this.InstanceGuid %>",
    templateDiv: "small-video-rotator",
});

```

And this is what i have in the `bellmedia.videoCarousel.videoHub.js`:

```
var BellMedia = BellMedia || {};
BellMedia.namespace('BellMedia.videoCarousel');

(function ($, _, utils) {
    BellMedia.videoCarousel.videoHub = function (options) {
        var intInterval = 0,
        isPlayerReady = false,
        //MORE CODE HERE
    }        
    };
})(jQuery, _, BellMedia.bravo.utils);

```

I included `bellmedia.videoCarousel.videoHub.js` in the web part file. 

And as you can see, the `videoHub` function is defined. But I am still getting the "videoHub" method not found message in Chrome Developer Tool Bar. 

Any help is greatly appreciated.
Thanks.

Answer: 
As I mentioned in comments, the mistake is that you are not skipping `len(x)` characters after match. Also `in` keyword is quite high-level routine (it does not less than **search** part of **search & replace**), so here is fixed version without `in`:

```
def rep_str(string, search, replacement):
    result = ''
    i = 0
    while i < len(string):
        if string[i : i + len(search)] == search:
            result += replacement
            i += len(search)
        else:
            result += string[i]
            i += 1
    return result

```
If you are allow to use the index() function, you can try this:

```
def main():
    s='IN GOING GO'
    x='IN'
    y='aa'

    print(rep_str(s,x,y))

def rep_str(s,x,y):
    while x in s:
        s = s[:s.index(x)] + y + s[s.index(x) + len(x):]

    return s

main()

```