I'm beginning to learn Python by following an introductory text and have come across an exercise that implements a for
loop to read files from a directory. I've used for
loops before in R and Java and I have some questions. I'm hoping the community could help me wrap my head around about for
loops in general.
It seems (in Python at least) that special characters and numbers can't be used as the "name" in loop. What's the reason for this?
ex:
for @ in data: print (@, end= ' ')
will produce an error. However replacing
@
withx
orname
for example is fine. Is this one of those things we accept, don't question, and move on?How does the
for
loop know (or evaluate) whether an object is "iterable"?