[Tutor] Newbie question: join() string method

Andreas Kostyrka andreas at kostyrka.org
Mon Nov 27 13:32:59 CET 2006

",".join(str(x) for x in intList)


_____ Ursprüngliche Mitteilung _____
Betreff:	[Tutor] Newbie question: join() string method
Autor:	"Moedeloos Overste" <kloosterjunkie at hotmail.com>
Datum:		27. November 2006 13:20:41


I'm trying to use the join() method on a list to be able to store the 
contents of that list in a file. Basically I want the contents of the list 
stored without the []. I've tried numerous ways of using the join() method, 
but they all return errors. I've tried using the tutorial and documentation 
on this one but still can't work it out.

errors: TypeError: sequence item 0: expected string, int found

LotNumbers = random.sample(range(1,45), 6) #random numbers from range into 
    ','.join()                                                  #?what's the 
correct syntax?
    fout = open("draw__output.dat", "a")
    fout.write(LotNumbers)                             #writing string to 
    vDraws = vDraws - 1

Can someone show me the correct way to use the join() method in this case?

Many thanks,


De makers van Hotmail hebben groot nieuws! Meer weten? Klik hier! 

Tutor maillist  -  Tutor at python.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20061127/065d2022/attachment.html 

More information about the Tutor mailing list