Feb-14-2018, 10:09 PM
(This post was last modified: Feb-14-2018, 10:09 PM by digitalmatic7.)
(Feb-14-2018, 09:29 AM)DeaD_EyE Wrote:def test(): return [1, 2, 3, 4, 5] def test2(): return [6, 7, 8, 9, 10] def test3(): return [11, 12, 13, 14, 15] final_list = test1() + test2() + test3() print() print(final_list)
I appreciate the help once again, DeaD_EyE !
I think I understand 'return' well enough to use it in my projects now.
Part of my confusion was passing multiple objects into a single return, then combining them outside the function, but it seems easy in this case (multiple lists I want to combine). I'm still not 100% sure how to return different object types, like for example a string and a list through return, because then it's like they're combined into a single variable when you call the function.
Is the rule to only return 1 kind of data per function?
def test1(): link_list1 = [1, 2, 3, 4, 5] link_list2 = [6, 7, 8, 9, 10] link_list3 = [11, 12, 13, 14, 15] return link_list1 + link_list2 + link_list3 def test2(): link_list4 = [16, 17, 18, 19, 20] link_list5 = [21, 22, 23, 24, 25] link_list6 = [26, 27, 28, 29, 30] return link_list4 + link_list5 + link_list6 final_list = test1() + test2() print() print(final_list)This forum is the best, its helped me overcome all the brick walls I've hit so far, you guys are amazing.