Python Lists and Dictionaries 8/14


#1

my_list = [1,9,3,8,5,7]

for cucumber in my_list:
print 2 * number

Why don’t I get the message about cucumber not defined?
How does Python know what the cucumber is?


#2

because you define cucumber inside the for loop, python will assign in order each value of the list to the loop iterator (cucumber in your case)


#3

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