I was wondering what the equivalent in python to this would be:
n = 100
x = (10 < n) ? 10 : n;
print x;
For some reason this does not work in Python. I know I can use an if statement but I was just curious if there is some shorter syntax.
Thanks.
x = min(n, 10)
Or, more generally:
x = 10 if 10<n else n
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With