Where does this term come from?

​names = ["Adam","Alex","Mariah","Martine","Columbus"]

for name in names:
  print name

Where does the term ‘name’ come from? Is is part of python? Or is it just the term names without the s, meaning any item plural has a term related that isn’t plural.

I couldn’t figure this one out because I didn’t know to type ‘name’, I instead typed ‘for x in names:’ like the example shows:

a = ["List", "of", "some", "sort"]
for x in a: 
  # Do something for every x

So is x just the non-plural form of a always?


the loop iterator (name or x, or any other valid variable name desired) is defined in the loop, python will then assign values from list to this variable (the loop iterator)


Ah, so just to be sure, ‘name’ (or whatever you choose to call it) in this example is called a loop iterator?


It’s basically a variable that iterates through your list of names.

for variable in names:
print variable


okay got it! I was like how the ■■■■ does python know what I mean by name, I wasn’t thinking broadly enough about python itself lol…


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