Answer:
In Python:
def sumLastPart(n,thelist):
sumlast = 0
lent = len(thelist)
lastN = lent - n
for i in range(lastN,lent):
sumlast+=thelist[i]
return sumlast
Step-by-step explanation:
This defines the function
def sumLastPart(n,thelist):
This initializes the sum to 0
sumlast = 0
This calculates the length of the list
lent = len(thelist)
This calculates the index of the last n digit
lastN = lent - n
This iterates through the list and adds up the last N digits
for i in range(lastN,lent):
sumlast+=thelist[i]
This returns the calculated sum
return sumlast