[Tutor] Newbie question: join() string method
jhlaks at gmail.com
Mon Nov 27 14:40:55 CET 2006
I am not sure what 'random' does (what package is it from?), but
does not. It appears 'join' only works on lists (and maybe tuples?) of
string objects and the list must be passed in as an argument. Try
translating your list into a list of string representation of numbers and
then using join.
Hope this is a useful clue,
On 11/27/06, Moedeloos Overste <kloosterjunkie at hotmail.com> wrote:
> 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()
> but they all return errors. I've tried using the tutorial and
> 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
> 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...
More information about the Tutor