Python Naming Error: List not defined - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Python Naming Error: List not defined (/thread-8938.html) |
Python Naming Error: List not defined - Intelligent_Agent0 - Mar-13-2018 I have begun working on a new function, I will keep things simple by not detailing the full scope of the function, which would be uneeded information for this question. I created a function which was to simply place a list object inside of another list object. The problem I am having is that even though the list object appears in the parent list, when I try to call it by name, python tells me the list is not defined. def date(D): """This function takes a list(date), and indexes it in another list('List_Of_Dates').""" List_Of_Dates.append(D) D=[] >>>date("March_13_2018") >>>List_Of_Dates [[]] >>>March_13_2018 [error][/error]***NAME ERROR***: March_13_2018 is not defined.From the output of the python interpreter, I can tell that my function is actually creating a list and appending it to List_Of_Dates. The problem seems to be that my name assignment "March_13_2018" is not being attached to the list object, what I get is a "nameless, or undefined" list. How do I map the name of the list that I pass through my function, so that the list that's created has that name? RE: Python Naming Error: List not defined - nilamo - Mar-13-2018 (Mar-13-2018, 07:37 PM)Intelligent_Agent0 Wrote: so that the list that's created has that name?Why would you care what the function's internal variable name is? While it's possible, that's a very wacky thing to do, like putting square tires on your car. |