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? Thanks for your help. On Mon, Jul 2, 2012 at 4:11 PM, Walter Prins <wpr...@gmail.com> wrote: > On 2 July 2012 23:55, Alexander Q. <alexxqu...@gmail.com> wrote: > > Hello- I'm wondering how to access specific objects returned from a > function > > when that function returns multiple objects. > > > > For example, if I have "return(list1, list2, list 3)" within a function > > When you have: > return (list1, list2, list3) > > ... you're actually returning a single tuple object. Read about > tuples in the documentation. To access an item from a tuple you index > into it, e.g. > > tupleresult = myfunc() > x = tupleresult[0] > > ... for example > > Walter. >
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor