0

I have a value that's need to be greater than some threshold. Right now I use it like this:

value = int(input())
threshold = 10

value = threshold if value < threshold else value

Are there any better ways to do it? Is it "Pythonic" enough?

Zhurik
  • 126
  • 3
  • 13

1 Answers1

2

You can use max() function (and there's min() if your threshold should cap the value)

value = max(threshold, value) 
Marcin Orlowski
  • 72,056
  • 11
  • 123
  • 141