functions are handy for encapsulating an idea for use and reuse in programand also for testing we can write function to number listand easily test it with different data read and run the example program numberentries py''use function to number the entries in any list''def numberlist(items)'''print each item in list itemsnumbered in order ''number for item in itemsprint(numberitemnumber number def main()numberlist(['red''orange''yellow''green']print(numberlist(['apples''pears''bananas']main(make sure you can follow the whole sequencestep by stepthis program has the most complicated flow of control so farchanging both for function calls and loops execution start with the very last linesince the previous lines are definitions then main starts executing the first call to numberlist effectively sets the formal parameter items ['red''orange''yellow''green'and the function executes just like the flow followed in numberentries py this timehoweverexecution returns to main an empty line is printed in the second line of main the second call to numberlist has different actual parameter ['apples''pears''bananas']so this effectively sets the formal parameter this time items ['apples''pears''bananas'and the function executes in similar pattern as in numberentries pybut with different data and one less time through the loop execution returns to mainbut there is nothing more to do accumulation loops suppose you want to add up all the numbers in listnums let us plan this as function from the beginningso read the code below we can start withdef sumlist(nums)'''return the sum of the numbers in nums ''if you do not see what to do right awaya useful thing to do is write down concrete caseand think how you would solve itin complete detail if nums is [ ]you would likely calculate is is is is the answer to be returned loops and sequences