I've noticed a weird behavior when iterating over a tuple containing only 1 string:
foo = ("hello")
for entry in foo:
print(entry)
outputs:
h
e
l
l
o
But I expect here to iterate only once, and output "hello" in a row.
If my tupple contains 2 entries, that's what happening:
foo = ("hello", "world!")
for entry in foo:
print(entry)
outputs:
hello
world!
Is it a bug in CPython's implementation? Even weirder, this doesn't occur if I use a list instead of a tuple:
foo = ["hello"]
for entry in foo:
print(entry)
outputs:
hello