First, I've sorted out my issue when I found this: in python: iterate over each string in a list
Originally I was getting what I thought was weird behavior when I would iterate over a "list" with a single string. In those instances, the string was being treated as a group of characters, and the iteration was sequentially returning each character in the string.
Being new to Python, I did not realize there's a somewhat strict difference between using [] and () to define a list. My list definitions were using (). However, when the lists would contain more than one string, the iteration was return each complete string sequentially. To illustrate:
list = ('string')
for i in list:
print i
Output:
s
t
r
i
n
g
But if i do this, that is, add a second string to the () group:
list = ('string','another string')
for i in list:
print i
It gets treated as if I used [] (as you're supposed to). Output:
string
another string
Now, I get the expected behavior either way if I use [] to define my lists, so that's what I'm doing now. I just thought this was interesting behavior.
Can someone point me towards some documentation that explains the way Python interprets parens, especially relative to strings?
I didn't see anything in the Python docs for data structures: https://docs.python.org/3/tutorial/datastructures.html
Thanks!