Python Forum
is there a single function to confine a number between two others?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
is there a single function to confine a number between two others?
#2
You're asking if one number has a value between two others? I'd do that initially with the operators like

lower <= n <= upper
I'm not sure this is what you meant by "confine"...

If they're all integers, you can also test it from a range, but that won't work for floats.

n in range(lower, upper + 1)
Reply


Messages In This Thread
RE: is there a single function to confine a number between two others? - by bowlofred - Nov-24-2020, 06:35 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Checking the number of arguments a function takes Chirumer 3 2,214 Jul-06-2021, 04:56 PM
Last Post: Chirumer
  Why is the function returning None for a * b instead of number? omm 10 4,396 Nov-05-2020, 01:17 PM
Last Post: omm
  RuntimeError: Optimal parameters not found: Number of calls to function has reached m bntayfur 0 6,187 Aug-05-2020, 04:41 PM
Last Post: bntayfur
  basic random number generator in replace function krug123 2 2,076 Jul-31-2020, 01:02 PM
Last Post: deanhystad
  Counting number of occurrences of a single digit in a list python_newbie09 12 5,644 Aug-12-2019, 01:31 PM
Last Post: perfringo
  My function won't return the sum unless the last paramater is an odd number. Maximuskiller78 1 2,351 Sep-29-2018, 03:11 AM
Last Post: ichabod801
  Write lambda function in pyhhon to coy data from multiple JSON into a single JSON fil anandmn85 2 4,279 Apr-19-2018, 05:56 AM
Last Post: anandmn85
  argument parser: to execute single function, and subsequent functions also raghu 10 5,944 Mar-12-2018, 06:57 AM
Last Post: wavic
  function for a single string number of syllables tebirkes 2 4,538 Nov-02-2016, 03:44 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020