📜  在 Python 代码示例中使用字典的三元运算符

📅  最后修改于: 2022-03-11 14:46:22.740000             🧑  作者: Mango

代码示例1
# declaring python variables
num1 = 10
num2= 5
# python ternary operator using dictionary
result = {True: "num1 is larger", False: "num2 is larger"}[num1 > num2]
# printing
print(result)