Posts: 4,647
Threads: 1,494
Joined: Sep 2016
is there a single function to confine a number between two others? i know i can do it with min() and max(), but that actually looks ugly. this should use 3 arguments.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Posts: 4,647
Threads: 1,494
Joined: Sep 2016
this:
def confine(a,n,b):
n=max(n,a)
n=min(n,b)
return n
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Posts: 4,647
Threads: 1,494
Joined: Sep 2016
how it reads in code the i want to be readable is my concern. the reduced code does not make it a readable as i want, hence my step-by-step in my confine() function.
i'm fine with using my own function. i have it in my big collection. i was just interested if i missed one in the Python library. but now i'm curious if someone can come up with a better name.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Posts: 4,647
Threads: 1,494
Joined: Sep 2016
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.