http://imgur.com/a/rfGhK#iVLQKSW

How do I code a function that returns a list of the first n elements of the 
sequence defined in the link? I have no idea!!!!!

So far this is my best shot at it (the problem with it is that the n that i'm 
subtracting or adding in the if/else part does not represent the element's 
position, but just the n that I am plugging into the function):

def reca(n):
    rlist=[0]
    while len(rlist) < n:
        if (rlist[-1]-n) > 0 and (rlist[-1]-n) not in rlist:
            rlist.append(rlist[-1]-n)
            
        else:
            rlist.append(rlist[-1]+n)
        
    return(rlist)
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to