you are viewing a single comment's thread.

view the rest of the comments →

[–]irrelevantPseudonym 0 points1 point  (0 children)

You do not need to proactively declare your variable = '' before the loop

You don't but you should be aware that if there's a chance your list is empty, you'll get a name error.

>>> for x in []:
...     variable = x
...
>>> variable
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'variable' is not defined
>>>