Python: condition between two values, in both directions quickly
Solved
Lecodeurhtmlcss
Posted messages
79
Status
Membre
-
Lecodeurhtmlcss Posted messages 79 Status Membre -
Lecodeurhtmlcss Posted messages 79 Status Membre -
Good evening!
I am working on a Python project that requires as much speed as possible; my level is rather beginner.
So, in one part of my code, I use a condition
Thank you very much!
--
(ง ͠° ͟ل͜ ͡°)ง щ(ಠ益ಠщ) (≖ ͜ʖ≖) Σ(⊙ロ⨀) ! /╲/╭(ఠఠ益ఠఠ)╮/╱\ \(º □ º l|l)/
I am working on a Python project that requires as much speed as possible; my level is rather beginner.
So, in one part of my code, I use a condition
ifthat needs to test if a value is between two others, like
a<machin<b. But the condition must also work for
a>machin>bbecause a and b are variables and can be negative! Is there a simple function to check
a>machin>b and a<machin<bmore logically?
Thank you very much!
--
(ง ͠° ͟ل͜ ͡°)ง щ(ಠ益ಠщ) (≖ ͜ʖ≖) Σ(⊙ロ⨀) ! /╲/╭(ఠఠ益ఠఠ)╮/╱\ \(º □ º l|l)/
1 réponse
yg_be
Posted messages
23437
Registration date
Status
Contributeur
Last intervention
Ambassadeur
1 587
Hello,
what have you tried?
what have you tried?
Ah ! I meant ! OR of course !
(And so I know that we can do , but isn't there a function like if machin between(a,b) ?)
No, it doesn't exist. But it's not hard to make.
In terms of speed, well it's a Python function, and in terms of usefulness, meh, usually we know what we need to compare in a program.