I have an array of numbers such as '17.2, 19.1, 20.4, 47.5, 34.2, 20.1, 19'
Trying to figure out a way to pick the first number to be over 20 (and none following) and the last number to be over 20 before falling below.
So far I've only tried to pick numbers between 20 and 23, but it's not ideal (see code for example)
nums = [15, 16.2, 17.1, 19.7, 20.2, 21.3, 46.2, 33.7, 27.3, 21.2, 20.1, 19.6]
test_lst = [x for x in nums if x >=20 and x<=23]
print test_lst
The output is as expected, but i'd like to have just the first and last number that first go over 20, without the rest. I realize this is probably trivial for most, newish to python