Undefined 'Number'?


#1

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

for number in start_list:
square_list.append(number ** 2)
square_list.sort()

print square_list

In this code, how is ‘number’ defined?


#2

It is defined in the for statement, and acts as a temporary variable to hold each value in the list, in turn.


#3

Thank you for clarifying!


#4

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