I am trying to solve the word break problem. But some input cases are not giving result.

**Code**

```
def wordBreak(words, word, out=''):

    # if the end of the string is reached,
    # print the output string
    if not word:
        print(out)
        return

    for i in range(1, len(word) + 1):
        # consider all prefixes of the current string
        prefix = word[:i]

        # if the prefix is present in the dictionary, add it to the
        # output string and recur for the remaining string
        if prefix in words:
            wordBreak(words, word[i:], out + ' ' + prefix)

# Word Break Problem Implementation
if __name__ == '__main__':

    # List of strings to represent a dictionary
    words = [
        'self', 'th', 'is', 'famous', 'Word', 'break', 'b', 'r',
        'e', 'a', 'k', 'br', 'bre', 'brea', 'ak', 'problem'
    ]

    # input string
    word = 'Wordbreakproblem'

    wordBreak(words, word)

```

**Present Output**

```
 Word b r e a k problem
 Word b r e ak problem
 Word br e a k problem
 Word br e ak problem
 Word bre a k problem
 Word bre ak problem
 Word brea k problem
 Word break problem

```

If `word = 'sWordbreakproblem'`, then the code is not giving any output. Here in this word, `s` at the beginning of the word, the output has to be `sWordbreakproblem`
and if `s` is at the end of the word then the output has to be like

```
 Word b r e a k problem s
 Word b r e ak problem s
 Word br e a k problem s
 Word br e ak problem s
 Word bre a k problem s
 Word bre ak problem s
 Word brea k problem s
 Word break problem s

```

If s is at the middle of the word like `Wordbreaksproblem`

```
 Word b r e a k sproblem 
 Word b r e ak sproblem 
 Word br e a k sproblem 
 Word br e ak sproblem 
 Word bre a k sproblem 
 Word bre ak sproblem 
 Word brea k sproblem 
 Word break sproblem

```