Merge the Tools!

  • + 0 comments

    A simple Core Python code with descriptions (as comments), and without using any inbuilt function or module:

    ` def merge_the_tools(string, k):

    string_split= [string[characters : characters+k] for characters in range(0, len(string), k)]
    
    # ['ADA', 'AAB', 'CAA'] -- Otput of string_split will be something like this (assuming k=3 here)
    
    for word in string_split:
        l= []  
        for letter in word:        
            # print(letter) ['A', 'D' 'A']- 1st Iteration
            if letter not in l:
                l.append(letter) 
        # print(l) -- ['A','D']   ['A', 'B']   ['C', 'A'] 
        print("".join(l))
    

    if name == 'main': string, k = input(), int(input()) merge_the_tools(string, k) `