On 07/02/2012 10:23 PM, Alexander Q. wrote: > I understand the basics of tuples, but that formulation returned the > following error: > > Traceback (most recent call last): > File "C:\Users\Owner\Desktop\MIT\Sets\Set3.py", line 34, in <module> > list4 = tuplesresult[1] > TypeError: 'NoneType' object is not subscriptable > > When I tried to assign "tuplesresult[1]" to the variable "list4" (after > assigning tuplesresult = mainFunc(), which is the name of the function that > returns the tuple in my program), the error occurred. That aside, is it all > right if I just code "return list1, list2" without the parens? In that > case, how would I access list1 and list2 when needed?
That's no different: list1, list2 is a tuple of size 2. > Thanks for your help. > You top-posted, which loses all the context of the earlier messages. Please put your new message AFTER the part you're quoting Anyway, you never showed the function mainFunc(), but from the error traceback message, it didn't return anything, which means None. Chances are you have something like: def mainFunc(): if something: return 4, 12 And if the if fails, the function will return None. To fix that, make sure all paths through the function return a similar object, generally a tuple of the same size. -- DaveA _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor