Python Lists and Dictionaries 8/14


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?


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)


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