Which I want to end up looking like this: 65īut so far the script only appends my 2 variables to the end of the. A common approach to write the elements of a list to a file using Python is to first loop through the elements of the list using a for loop. In this tutorial you will see how to do that in multiple ways. Print("print 2 lines right before this line")Īnd this is the test. Knowing how to write the elements of a list to a file in Python can be handy. New_data = str(new_num) '\n' 'Georph' txt for the 1st number that is >= to my integer variable and then I want to write my integer and name above the found number (I need them on a new line, and each variable on a separate line). I then have 2 variables, an integer and a name. ![]() ![]() txt with alternating names and numbers (the numbers ordered from lowest to highest). I am trying to take numbers from a file, assign them a variable name, do some math on the variable, and write to the next line in the file.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |