If I have a code like:
def foo(a):
    for i in range(len(a)):
        do something
        return a
def main():
    while len(a) > 1:
        n = int(a[0])
        print(foo((a[:n+1])))
        a = a[n+1:]
Q1: How do I compute the run time to see which part of my code is not efficient?
Q2:
Is there a way to iterate through a list continuously but only use a section of it? for example lets say a = [1, 2, 3, 4, 7, 8, 8].
I want to run it from [1, 2, 3, 4] then print a value then run the rest of the list ([7, 8, 9]). Is the only way to do this through slicing?
 
     
    