Here is the code that I have used and reference in this post:
alpha=["One", "Two", "Three"]
beta=["One", "Two", "Three"]
charlie=["One", "Two", "Three"]
import random
alpharandom=random.randint(0,2)
betarandom=random.randint(0,2)
charlierandom=random.randint(0,2)
stringcode=(alpha[alpharandom],beta[betarandom],charlie[charlierandom])
stringcodetwo=str(stringcode).replace(" ", "")
print(stringcodetwo)
I am using python 3.0 to generate a random string using predefined items from lists. This results in an output similar to:
('Two','One','Two')
However, would it be possible to generate so that the brackets, commas and quotation marks are omitted? I have tried the replace
function, but that only seems to work for the spaces between the generated string.
An example of a desired output would be:
TwoOneTwo