Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Syl |
Greets!
Meaning, is there a better way to write:
if var > 0 and var < 11:
like:
if var 1-10:
?
Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Syl |
Greets!
Meaning, is there a better way to write:
if var > 0 and var < 11:
like:
if var 1-10:
?
Reply From: | jgodfrey |
You can use &&
instead of and
to save a single character… ;^)
Otherwise, you could write a function that, with a short name, might be less code. Personally, I’d just stick the standard syntax (though, I do prefer &&
).
Ok for && then. Thxs!
Syl | 2020-02-25 00:30
Reply From: | Zylann |
If you have integers I guess var in range(1, 10)
would work but it’s pretty inefficient under the hood because it creates an array of that lenght.
What you wrote remains the best way.
You mean what jgodfrey wrote?
Syl | 2020-02-25 01:19
It’s just the same with one less character^^ I prefer and
for readability
Zylann | 2020-02-25 01:32
Yes, strange that there’s nothing better.
Syl | 2020-02-25 01:45