Click to See Complete Forum and Search --> : Printing a list in Python


dannybunkins
12-04-2005, 02:55 PM
Hello all, I am working on a python program in which I assign a string to a list, and then am required to print that string randomized in a normal format. here is an example


#this will print "hello" randomized
>>>print random.shuffle(myList)
[o, h, l, e, l]


I want it to do this instead


#this will print "hello" randomized
>>>print random.shuffle(myList)
ohlel


I dont want the brackets or the commas, if there is a quick way built into python to do this, I would be greately appreciative is you told me, or at least pointed me to a tutorial or website that I could find out how to do this.

hopefully this is clear, if it is not please post back and tell me what I need to explain.

bwkaz
12-04-2005, 04:19 PM
I don't think there's any easy way, but you might try brute-force:

s = ""

for item in random.shuffle(myList):
s = s + str(item)

print s and see if that helps.