Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Mar 6th, 2005, 9:55 PM   #1
arod199113
Programmer
 
arod199113's Avatar
 
Join Date: Feb 2005
Posts: 86
Rep Power: 0 arod199113 is an unknown quantity at this point
for?

can someone explain this for me?
for count in range(1,11):
        print count
i understand range
i dont understand "for count in"
is count a variable?
if it is a variable how is it "in" range?
arod199113 is offline   Reply With Quote
Old Mar 6th, 2005, 10:48 PM   #2
block01cube
Newbie
 
Join Date: Feb 2005
Posts: 10
Rep Power: 0 block01cube is on a distinguished road
You are correct that count is a variable.

Basically:

the code for count in range(1,11) is equivalent to saying: run the following loop for every object in the list created by the range function.

The variable count (or whatever you want to call it) provides a hook into whatever iteration you are currently on.

i.e.:

for i in range(1,5):
   print "i is now: ", i
will give the output:

i is now: 1
i is now: 2
i is now: 3
i is now: 4

------------------

Hope that helps!

Cheers,

b01c
block01cube is offline   Reply With Quote
Old Mar 7th, 2005, 5:33 PM   #3
arod199113
Programmer
 
arod199113's Avatar
 
Join Date: Feb 2005
Posts: 86
Rep Power: 0 arod199113 is an unknown quantity at this point
it helps a little
but enough for me to understand it
arod199113 is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 12:16 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC