Ad
  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    yeah actually i removed l from the outer loop though it had no effect and m just accumulates the words that are present in the dictionary
    but for cases like

    valid_word(['a', 'bgkol', 'a', 'k'],'aakbgkolbgkol')
    valid_word(['ab', 'a', 'bc'],'abc')
    

    it isn't working!

  • Custom User Avatar
    l=0
    for o in range(0,len(word)-l):
      
      ...
    
      l += 1
    

    What you are doing with l has no effect on the for loop, in case you are relying on that somehow. You might as well write for o in range(0, len(word)):...
    Also, m just keeps accumulating letters without discrimination. In the end it will simply be a concatenation of the input sequence.

  • Default User Avatar

    this is the code above
    its not passing for test cases like these:

    print(valid_word(['a', 'bgkol', 'a', 'k'],'aakbgkolbgkol'))
    print(valid_word(['ab', 'a', 'bc'],'abc'))
    

    kindly review it Thanks!

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    Please use the spoiler tag if you are going to post solution code (even non-working) in the discourse.
    Also, if you decide to post code, use markdown formatting:

    ```

    your code

    ```

    Otherwise, we can't make heads or tails from what you wrote (indentation matters in python).

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution