# for you lists just a question for understanding


num is not defined, how does python know what it means?

code works fine

numbers  = [7, 9, 12, 54, 99]

print "This list contains: "

for num in numbers:
    print num

# Add your loop below!
for num in numbers:
    print num ** 2


python is making a for loop very easy for you.

look at the loop:

for num in numbers:
   print num

num gets at assigned (in order) the items in the list, so num gets defined in the for loop


num is defined, in the for statement. It is the iterator variable that temporarily holds each element's value while the list is iterated.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.