"For One and All", "More with For" Re: "Number Variable


#1



https://www.codecademy.com/courses/python-beginner-en-pwmb1/1/6?curriculum_id=4f89dab3d788890003000096#


This may be a dumb question, because I'm VERY new at this, but I'm a little confused as to where the variable "number" is coming from. It is used in both the "For One and All" and "More with For" exercises. Obviously, the list contains numbers, but I don't really understand where this variable is defined.


start_list = [5, 3, 1, 2, 4]
square_list = []

# Your code here!
for number in start_list:
    square_list.append(number ** 2)
square_list.sort()
print square_list


#2

It is defined in the loop statement as the block variable that temporarily holds the value at one point at a time in the list being iterated.


#3

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