[Tutor] Create file / Print list to file
klas.martelleur at telia.com
Wed Aug 11 19:58:01 CEST 2004
Hi and thanks for all the previous answers. I am still struggling with my
Here are todays questions :)
1. Is it possible to tell python to create a file (for example if specified
file doesnt exist)? It sems possible to create a directory thrue the os
module. But i cant find out how to create a file.
2. How can i print a list to a file? I have tried the following:
def writeListToFile(inputList, outputFile):
a = open(outputFile, "w")
listLength = len(inputList)
for i in range(0,listLength):
but i get a "Type error"
inputList is list of lists (each row is list)
More information about the Tutor