Merge the Tools!

  • + 0 comments
    def merge_the_tools(string, k):
    # while loop runs till the string becomes empty
    while string:
        # splice the given string
        s = string[0:k]
        # initiate an empty string
        # (seen is just the name of our variable)
        seen = ''
        # run a for loop through our spliced string (s),
        # appending only unique characters to our variable seen
        for c in s:
            if c not in seen:
                seen += c
        print(seen)
        # remove the spliced part from original string for the next iteration
        string = string[k:]