Ternary expression

a = 5

b =4

c = a if a > b else b # Ternary expression (if a is greater than b, c = a, otherwise c = b)

equivalent

# if a > b:
#    c = a
# else:
#   c = b

print(c)

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325253477&siteId=291194637