How to store an if statement in a variable in Python

Is there a way to store an if statement in a variable that I can then print to the screen? It's an if statement with one elif and else- it's keeping scores in a game and prints who won with print statements but I need to print it using pygame font library to the screen. So, I only need the outcome of the if statement to be printed, so I thought storing it in a variable could help, but I'm having a problem figuring out how to do it.
1 Reply
ErickO
ErickO14mo ago
you cannot store the result of an expression (if statement) inside a variable what do you mean by "outcome of the if statement" if you mean something like "if a < b the variable should be a else it should be b" then you can do
min = a if a < b else b
min = a if a < b else b
Want results from more Discord servers?
Add your server