So, I have a two part question for you...

I'm going to be writing several lines of code to a .txt file, but I won't know what each line is, or how many there will be. There could easily be hundreds of lines. I need to add a prefix to the front of each individual line. Is such a thing possible, when you don't know how many lines there are going to be? (It will all be contained within a list before being written to the file, btw.)

And second question... if I potentially had say, over 1000 lines of text, would the list be able to hold them all? I haven't seen any mention of lists' limitations anywhere, so I'm not sure if there is a limit or not, but I'm just asking to be safe.

Thanks for the help.

(Lol, whoops... I wrote string in the title instead of list. My bad.)

Edited 5 Years Ago by Lemony Lime: n/a

To answer your second question, try it out yourself in IDLE, what a quick for loop that creates a list and adds 1000 lines of some random sentence. TIP: It works :-)

Your first question, sure I don't see anything that can't be done there. Just write the txt file line by line and add the prefix just before you write the line to the file.

This question has already been answered. Start a new discussion instead.