I have this script that picks up random words from an URL and it concatenates with other special characters stored in a list:
import requests
import random
from random import randint
import string
url = 'https://svnweb.freebsd.org/csrg/share/dict/words?view=co&content-type=text/plain'
r = requests.get(url)
text = r.text
words = text.split()
random_num = randint(0, len(words))
random_num2 = [randint(0,10)]
special_list = ['#','!','@','-', '@']
union = "".join(str(x) for x in special_list)
special_char = random.choices(union, k=2)
special_char2 = random.choices(union)
final_string = (str(special_char).strip('[]') + words[random_num] + '__' +
str(random_num2).strip('[]') + str(special_char2).strip('[]'))
The output is something like that: '-', '@'auxiliary__2'-'.
The problem is even if I use .join I cannot get rid of '' and concatenate everything together.
I also tried with:
random_char = ''.join(string.punctuation for i in range(0,1))
instead using a special character list, but also this didn't work.
range(0,1) == [0]