Python Program that prints the count of either peaks or valleys from a list
Given a List, the following article shows ways to count elements which are either peak(x > y < z) or valley(x < y > z). Input : test_list = [1, 2, 4, 2, 6, 7, 8, 3] Output : 3 Explanation : (2, 4, 2), (4, 2, 6), (7, 8, 3) are peaks and valleys. Input : test_list = [1, 2, 4, 5, 3, 2] Outp