I'm currently working on an word encrypter and I wanted a letter to have multiple "translations", so I made lists for each letter contaning different translations. Using a for loop and the random module, I am able to check and replace the letters from an input with a random character from the letter's list. Example:
import random
d= ["°", "┌", "Ï"]
o= ["‗", "‥", "ӟ"]
word = "do"
for i in range(len(word)):
if word[i]=="d":
print(random.choices(d), end="")
if word[i]=="o":
print(random.choices(o), end="")
This code is going to replace the letters with a random character from their respective list. Here is the problem: the output of the random choices in brackets (it outputs ['°']['‥']
instead of °‥
). Is there any way to remove the brackets?
Aucun commentaire:
Enregistrer un commentaire