[Tutor] :initialize a for loop

Alan Gauld alan.gauld at btinternet.com
Fri Jan 2 17:45:16 CET 2009


"i i" <iaidas4 at gmail.com> wrote in

>    self.numOne = random.randint(1,10)
>    for i in range(self.numOne):
>         self.image = gtk.Image()
>         self.image.set_from_file("./Pink-Flower-32x32.png")
>         self.fixed.put(self.image, i*25, 0)
>         self.image.show()
>
> images,i want to initialize the array or empty it before the next 
> loop.
> how can we initialize or empty a for-in statement in python.

I don't understand the question? What is it you want to initialise
or empty?

Do you just want to break out of the loop?
Do you want to clear the images you have already created
at some point?

Can you show us some pseudo code that would illustrate
how you would like the program to work?


-- 
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld 




More information about the Tutor mailing list