0
Valley numbers
A list of integers is said to be a valley if it consists of a sequence of strictly decreasing values followed by a sequence of strictly increasing values. The decreasing and increasing sequences must be of length at least 2. The last value of the decreasing sequence is the first value of the increasing sequence. Write a Python function valley(l) that takes a list of integers and returns True if l is a valley and False otherwise. ******************************************************************************************** Here are some examples to show how your function should work. >>> valley([3,2,1,2,3]) True >>> valley([3,2,1]) False >>> valley([3,3,2,1,2]) False
4 Answers
+ 5
It's the reverse of mountain peak sequence, right?
https://code.sololearn.com/W4XnnoB3gk7E/?ref=app
+ 3
https://code.sololearn.com/cElE5XPYRK1y/?ref=app
0
Answer
0
sequence of strictly increasing values. The decreasing and increasing sequences must be of length at least 2.
The last value of the decreasing sequence is the first value of the increasing sequence.Write a Python
function valley(l) that takes a list of integers and returns True if l is a valley and False otherwise.
Here are some examples to show how your function should work.
>>> valley([3,3,2,1,2])
False
4