[Tutor] Counting the # of iterations OR storing # values in a list

Alan Gauld alan.gauld at yahoo.co.uk
Mon Aug 13 04:20:53 EDT 2018


On 13/08/18 06:15, Gautam Desai wrote:

> I am currently working with the lattice.py code attached. 

The server doesn't like attachments so strips them off
for security. As a result we can't see the code.

Please resend, but paste the code into the body of your
message (in plain text to preserve formatting).
It would be helpful to also include your OS and
Python version.

> lattice. I could count the number of red or blue bacteria on the output,
> but with a size of 250 that would take an extremely long time.

250 of anything is not very much in computing terms
(even if your lattice is 250 cubed its still not
unusually big). But I guess it depends on what the data
elements look like.

> I need to keep track of the number of red or blue cells in lists, and while
> I know how to instantiate a list, I don't know how to store the information
> I need in the list with the code given.

We can't see the code but the most common operation for
adding data to a list is the append() method

mylist.append(anObject)

But we can say more when we see the code.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list