given a nonempty string s and a dictionary worddict containing a list of nonempty words determine if word can be segmented into a spaceseparated sequence of one or more dictionary words you may assume the dictionary does not contain duplicate words for example given word leetcode dict leet code return true because leetcode can be segmented as leet code word abc worddict a bc true false false false tc on2 sc on type word str type worddict setstr rtype bool tc o n 2 sc o n type word str type word_dict set str rtype bool
def word_break(word, word_dict):
    
    dp_array = [False] * (len(word)+1)
    dp_array[0] = True
    for i in range(1, len(word)+1):
        for j in range(0, i):
            if dp_array[j] and word[j:i] in word_dict:
                dp_array[i] = True
                break
    return dp_array[-1]


if __name__ == "__main__":
    STR = "keonkim"
    dic = ["keon", "kim"]

    print(word_break(str, dic))