Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Returns all the values in given list,
- # which are between mn and mx.
- def values_between(lst, mn, mx):
- result = []
- # Iterate through the list
- for i in lst:
- # If current number is smaller than mx AND larger than mn,
- # append it to the result list.
- if mn < i < mx:
- result.append(i)
- return result
- # Tests
- # With list of integers
- print(values_between([1, 15, 4, 8, 10, 32, 69], 3, 10))
- # With list of floats
- print(values_between([1.2, 5.06, 3.5, 1.1, 4.0, 2.9874, 3.33], 1.15, 3.6))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement