python 递增递减数列

 

def is_arithmetic(l):  
    delta = l[1] - l[0]  
    for index in range(len(l) - 1):  
        if not (l[index + 1] - l[index] == delta):  
             return False  
    return True  
  
print(is_arithmetic([5, 7, 9, 11]))  
print(is_arithmetic([5, 8, 9, 11]))

 

转载于:https://www.cnblogs.com/sea-stream/p/9961970.html

你可能感兴趣的:(python 递增递减数列)