Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Python
the PHP ternary operator equivalent on Python
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Steve M, post: 1849294"] Another way to simulate the ternary operator is this: a = (quantity > 90 and "It is very huge") or "The value is correct" You have to be careful of semantics of 'and' and 'or'. But in this case I wonder why you don't just test whether quantity is greater than 90 and assign the corresponding value to a, e.g., : if quantity > 90: a = "It is huge" else: a = "Time for tea." Clarity is a virtue, and simulating ternary operator doesn't always serve that end. [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Python
the PHP ternary operator equivalent on Python
Top