Here is a for loop operating on a list of string items:
data = ["string 1", "string 2", "string 3", "string 4", "string 5", "string 6",
"string 7", "string 8", "string 9", "string 10", "string 11"]
result = ""
for item in data:
result = item + "\n"
print result
I want to replace the for loop with a List Comrehension (or whatever) to
improve performance (as the data list will be >10,000]. At each stage of the
for loop I want to print the result ie.
[print (item + "\n") for item in data]
But, this doesn't work as the inclusion of the print causes an invalid syntax
error.
Any thoughts?
Dinesh
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor