Search code examples
pythonstringlistintconcatenation

Can't concatenate string with integer


I was writing a script in Python to generate brute force wordlists. I already can concatenate only strings, but I cant concatenate some random numbers in the final of each word in list, because it says that I cannot concatenate str and int objects...

The code:

wList = []

words = raw_input("[+]Insert the words that you wish: ")
outputFile = raw_input("[+]Insert the path to save the file: ")

wordList = words.split(",")

for x in wordList:
    for y in wordList:
        wList.append(x + y)
        wList.append(y + x)
        wList.append(x + "-" + y)
        wList.append(y + "-" + x)
        wList.append(x + "_" + y)
        wList.append(y + "_" + x)
        wList.append(x + "@" + y)
        wList.append(y + "@" + x)


for num in wordList:
    for num2 in wordList:
        for salt in range(1,10):
            wList.append(num + num2 + int(salt))
            wList.append(num2 + num + int(salt))

Solution

  • You can only concatenate a string with another string in Python.

    Change the last two lines to below:

    wList.append(num + num2 + str(salt))
    wList.append(num2 + num + str(salt))