How to create all possible combinations of words (python)

Discussion in 'Programming' started by hamoodrex, Jan 11, 2020.

  1. Code (Text):
    #This python program will create a dictionary containing all possible combinations
    length = int(input("Write how many characters: "))
    alphabet = [chr(i) for i in range(97, 97+26)]
    file = open("dictionary.txt","w");
    lst = ["" for k in range(length)]
    for i in range(chars**length):
        for j in range(length):
            x = (i//(chars**(length-j-1)))%chars
            h = alphabet[x]
            lst[j] = h
    jk = input("")
    I wrote this in python for you to make use of it in a good way. This will create all possible combinations of characters in the list alphabet and with a given amount of word length!
    #1 hamoodrex, Jan 11, 2020
    Last edited: Jan 11, 2020
    • Useful Useful x 1