![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Programmer
Join Date: Feb 2005
Posts: 86
Rep Power: 0
![]() |
for?
can someone explain this for me?
for count in range(1,11):
print counti dont understand "for count in" is count a variable? if it is a variable how is it "in" range? |
|
|
|
|
|
#2 |
|
Newbie
Join Date: Feb 2005
Posts: 10
Rep Power: 0
![]() |
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 i is now: 1 i is now: 2 i is now: 3 i is now: 4 ------------------ Hope that helps! Cheers, b01c |
|
|
|
|
|
#3 |
|
Programmer
Join Date: Feb 2005
Posts: 86
Rep Power: 0
![]() |
it helps a little
but enough for me to understand it |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|