On 2014-02-13 17:46, eneskri...@gmail.com wrote:
Can we please revert back to the original problem?
     def save():
>          target = open ("save.swroc", 'w')

This opens the file for writing text (assuming you're using Python 3).

> target.write([counter, loop, number_of_competitors, competitors])

This tries to write a list to the file. You can't do that. A list isn't
text.

     def load():
         the_array = list(open("save.swroc", 'r'))

This open the file for reading text. Using 'list' will make it read
lines of text and return them as a list.

         the_array = target

What's 'target'?

         counter = the_array[0]

This will set 'counter' to the first line of text that was read.

         loop = the_array[1]

This will set 'loop' to the second line of text.

         number_of_competitors = the_array[2]

This will set 'number_of_competitors' to the third line of text.

         competitors = the_array[3]

This will set 'number_of_competitors' to the fourth line of text.

Is this better?

Not really! :-)

Have a look at the "pickle" module, or the "json" module.
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to