Python Forum

Full Version: Print variable without '' and spaces
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello all,
could you help me with below question:

x = int(input("Enter the number:"))
a = str(([random.choice("ABCD" for _ in range(x)]))
var1 = 'X'
var2 = 'Y'
var3 = 'Z'

print (a) - this function display e.g. ['T', 'C', 'A'] I need display like string ['TCA']

b = ""
for char in a:
if char == "X":
b.join(var1)
if char == "Y":
b.join(var2)
if char == "Z":
b.join(var3)
b = b.split()
print (b) - this function display correct e.g. ['YZX']
None of your code makes any sense. What are you trying to do? Are your trying to make a three-letter string?