python – Set the price of the low-cost ticket, with a floor of 0

Python has a syntax for ternary since 2.5.

The syntax for this is if condition if not b, where the condition is a boolean.

You can rewrite your code as follows:

discounted_price = original_ticket_price - discount_value
discounted_price if discounted_price> = 0 otherwise 0

Personally, I have trouble reading, but it's another way to write your code.

EDIT you can find more info about ternary in this article