See the following code :
choices = ['pizza', 'pasta', 'salad', 'nachos']
print 'Your choices are:'
for index, item in enumerate(choices):
print index+1, item
Output:
Your choices are:
1 pizza
2 pasta
3 salad
4 nachos
None
In the third line, for takes two arguments.
for index, item in enumerate(choices):
But the syntax of for loop is:
array=[...]
for element in array
How does this actually work? Does for loop take in multiple arguments? If yes, how can we use them?
forloop is actuallyfor things in otherThings, notfor elem in array: docs.python.org/2/reference/compound_stmts.html#for