On Fri, Dec 5, 2014 at 7:09 AM, LJ <luisjoseno...@gmail.com> wrote: > def gt(l): > a["1"] = a["1"] | set([l]) > > > def gt2(l): > b=b+l
These two may both look like they're assigning something, but one of them is assigning directly to the name "b", while the other assigns to a subscripted element of "a". In the first function, "a" is still the same object after the change; in the second, "b" has been replaced by a new object. That's why your second one needs a global declaration. It's all about names and assignment; if you're not assigning to the actual name, there's no need to declare where the name comes from, because you're only referencing it, not replacing it. ChrisA -- https://mail.python.org/mailman/listinfo/python-list