Your C code doesn't contain two return statements. Neither should your python code... The translation of your ternary expression is n if n<m else m, so just use that expression when you return the value:

def minn(n,m):
    return n if n<m else m
Answer from Karoly Horvath on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › python › ternary-operator-in-python
Ternary Operator in Python - GeeksforGeeks
The ternary operator in Python ... expression because it evaluates a condition and returns one value if the condition is True and another if it is False....
Published   December 20, 2025
Discussions

I think the ternary operator would be more readable if the order was reversed
Python does something similar: a = b if condition else c But I feel like it's less readable. A lot of people hate the ternary operator because they think it's not very readable, but I'm quite fond of it. If things get long I type it like: a = Condition ? b : c Which I find to be perfectly readable. Oh well. More on reddit.com
🌐 r/ProgrammingLanguages
57
0
June 20, 2024
Conditional Expresion/Statements - Ideas - Discussions on Python.org
Quite often when coding I feel like this would be a very logical way to express things retries -= 1 if logical_condition retries = function_call() if logical_condition return if logical_condition return None if logical condition Obviously this can be seen as nothing new given that both can ... More on discuss.python.org
🌐 discuss.python.org
0
March 26, 2023
Is using the ternary operator bad practice?
If you don't abuse the ternary operator as if replacement and if there is no nesting, it is perfectly fine to use the ternary operator. Actually, it is far more elegant to write int y = (x > 0) ? x : x * (-1); Than int y; if (x > 0) { y = x; } else { y = x * (-1); } Nested ternary operators are a no-go. More on reddit.com
🌐 r/learnprogramming
11
1
February 2, 2022
Python's Boolean operators do not return Boolean
Kind of reminds me of C++ and C, and the wild-west of operations you can do there. Adding and multiplying booleans, or dividing by letters, etc., That stated, I'm teaching myself Python right now, and this is a good thing to know as an interesting quirk. Cool knowledge. Thanks. More on reddit.com
🌐 r/ProgrammerTIL
14
96
May 5, 2021
🌐
Dataquest
dataquest.io › blog › python-ternary-operator
Python Ternary: How to Use It and Why It's Useful (with Examples)
March 6, 2023 - If the standard syntax for the Python ternary operator is a if condition else b, here we would re-write it as (b, a)[condition], like this: t = 90 ('Water is not boiling', 'Water is boiling')[t >= 100] ... In the syntax above, the first item of the tuple is the value that will be returned if the condition evaluates to False (since False==0), while the second is the value that will be returned if the condition evaluates to True (since True==1).
🌐
Sentry
sentry.io › sentry answers › python › does python have a ternary conditional operator?
Does Python Have a Ternary Conditional Operator? | Sentry
July 12, 2022 - The operator checks a condition, and returns x if the condition is true or y if it’s not. Here is an example of a ternary operator use case: ... The ternary operator above checks if x is greater than y, and if it is, assigns the value of x (10) to the variable z. If you’re looking for information on Python application monitoring, check out these links from our blog:
🌐
Reddit
reddit.com › r/programminglanguages › i think the ternary operator would be more readable if the order was reversed
r/ProgrammingLanguages on Reddit: I think the ternary operator would be more readable if the order was reversed
June 20, 2024 -

So currently all implementations of the ternary operator go something like this:

a = (Condition) ? b : c

However I feel like that quite often I just want to see the possible outcomes first and then look at the condition. I feel like when the conditions get a bit longer it quickly becomes hard to read. The outcomes are almost always simple because I wouldn't use a ternary operator if that wasn't the case.

I feel like this format would be more readable in 90% of cases I encounter:

a = b : c ? (Condition)

Potential downside is that it is a bit more removed from the logical execution order perhaps.

It might be a small thing but I feel like I would use the ternary operator more if it was easier to read at a glance.

What do you think?

🌐
Mimo
mimo.org › glossary › python › ternary-operator
Python Ternary Operator: Syntax, Usage, and Examples
The ternary operator (also called ... Syntax:value_if_true if condition else value_if_false · The condition is evaluated first. If the condition is True, value_if_true is returned....
🌐
Python.org
discuss.python.org › ideas
Conditional Expresion/Statements - Ideas - Discussions on Python.org
March 26, 2023 - Quite often when coding I feel like this would be a very logical way to express things retries -= 1 if logical_condition retries = function_call() if logical_condition return if logical_condition return None if logical condition Obviously this can be seen as nothing new given that both can be written as if logical_condition: retries -= 1 if logical_condition: retries = function_call() if logical_condition: return if logical_condition: return None It is probably because the...
Find elsewhere
🌐
Hacker News
news.ycombinator.com › item
> Python programmers in general have an irrational aversion to if-expressions, a... | Hacker News
September 4, 2021 - Because the Python ternary operator is fucking backwards! Why on earth would you put the condition in the middle · x = 4 if condition() else 5 vs.:
🌐
Scaler
scaler.com › home › topics › python › ternary operator in python
Ternary Operator in Python - Scaler Topics
April 21, 2023 - The ternary operator in Python is a concise way of writing simple if/else statements in a single line. It returns a true or false value by evaluating a boolean condition. It is shorter and more readable than simple if/else statements.
🌐
Python Tips
book.pythontips.com › en › latest › ternary_operators.html
6. Ternary Operators — Python Tips 0.1 documentation
In python there is also the shorthand ... Python 2.5 and can be used in python 2.5 or greater. ... The first statement (True or “Some”) will return True and the second statement (False or “Some”) will return Some....
🌐
Python-practice
python-practice.com › learn › logic › ternary
Python Ternary Operator - Practice Python Questions
Practice Python code problems with an online terminal. Solve Python questions using a practice question list. Learn and improve your Python skills.
🌐
Towards Data Science
towardsdatascience.com › home › latest › ternary operators in python
Ternary Operators in Python | Towards Data Science
January 15, 2025 - If it evaluates to True, then x is evaluated and its value will be returned (and assigned to the variable min). Otherwise, y is evaluated and its value is returned (and assigned to the variable min).
🌐
DataCamp
datacamp.com › tutorial › pythons-ternary-operators-guide
Python's Ternary Operators Guide: Boosting Code Efficiency | DataCamp
May 17, 2024 - The syntax of a ternary operator in Python is value_if_true if condition else value_if_false. It evaluates the condition first; if it's true, it returns value_if_true; otherwise, it returns value_if_false
🌐
Wiingy
wiingy.com › home › learn › python › ternary operators in python
Ternary Operators in Python
January 30, 2025 - Here is an example of how the conditional expression would be written before Python 2.5: 1x = 5 2result = (x + 1) if (x > 0) else (x - 1) 3 · In this example, we are checking whether x is greater than 0. If it is, then the value x + 1 is returned. Otherwise, the value x – 1 is returned. This is achieved using the if and else statements within parentheses. However, this method is less readable and more confusing than the ternary operator.
🌐
Syntaxdb
syntaxdb.com › ref › python › ternary
Ternary Operator in Python - SyntaxDB - Python Syntax Reference
The ternary operator is used to return a value based on the result of a binary condition. It takes in a binary condition as input, which makes it similar to an 'if-else' control flow block. It also, however, returns a value, behaving similar to a function.
🌐
Flexiple
flexiple.com › python › python-ternary
Python ternary operators - How to use them? - Flexiple Tutorials - Flexiple
March 11, 2022 - If the result is true, then it returns the val_true, which in this case is “Yes, you can drive!”. Else it returns val_false, which is Sorry, you can’t drive yet!” · As we now have an understanding of how Python’s ternary operator ...
🌐
DEV Community
dev.to › askyt › python-ternary-operator-a-comprehensive-guide-274i
Python Ternary Operator: A Comprehensive Guide - DEV Community
December 14, 2024 - The Python ternary operator is a compact and elegant way to implement conditional logic, allowing you to evaluate a condition and return a value based on its result — all in a single line of code.
🌐
WsCube Tech
wscubetech.com › resources › python › ternary-operator
Ternary Operator in Python (Conditional Operator With Example)
October 1, 2025 - Learn how to use the Ternary Operator in Python, also known as the Conditional Operator, for concise one-line if-else statements in your Python code.
🌐
Board Infinity
boardinfinity.com › blog › ternary-operator-in-python
Ternary Operator in Python | Board Infinity
July 11, 2023 - The value corresponding to True is returned if the conditional expression evaluates to True. In all other cases, the False value is returned. ... We have now reached the end of the article.
🌐
Python documentation
docs.python.org › 3 › reference › expressions.html
6. Expressions — Python 3.14.3 documentation
1 week ago - A conditional expression (sometimes called a “ternary operator”) is an alternative to the if-else statement. As it is an expression, it returns a value and can appear as a sub-expression.