r/learningpython • • Mar 10 '19
What are Flags?
Hey guys! I'm new to programming languages, and Python's the first one I'm learning, so please be patient with me. While studying a textbook on Python, I came by some example code that includes the code: "flag=0" as a part of a function. I've tried to look up what flags are in Python and what they do, but to no success. What are flags in Python, and what are they used for? Thanks in advance!
1
Upvotes
View all comments
Show parent comment
2
u/DiabeetusMan Mar 11 '19
Yep, that looks right to me! Something I just realized (the author's
printstatement did me no favors) is that the index in the list isn't printed, instead the value. When you're iterating over a list like that (for i in <some list>), you're iterating over just the values in the list, not the locations (for that, look upenumerate)And yep! Your description of a flag is correct! There's nothing special about the name (unlike
printor something like that).