for loop question
Preston Hagar
prestonh at gmail.com
Thu Jul 6 17:01:44 EDT 2006
On 7/6/06, bruce <bedouglas at earthlink.net> wrote:
>
> hi..
>
> basic foor/loop question..
>
> i can do:
>
> for a in foo
> print a
>
> if i want to do something like
> for a, 2, foo
> print foo
>
> where go from 2, to foo..
>
> i can't figure out how to accomplish this...
>
> can someone point me to how/where this is demonstrated...
>
>
> You might want to look here:
http://www.freenetpages.co.uk/hp/alan.gauld/tutloops.htm
I am not exactly sure what you are asking, so perhaps a hopefully related
example will help you on your way.
Let's say you have a variable foo and want to count from 2 to the value of
foo, you could do the following:
foo = 20
for i in range(2,foo):
print i
This would print the numbers 2 through 29 out.
Hope this helps.
Preston
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20060706/fd98df34/attachment.html>
More information about the Python-list
mailing list