# Traditional way <pre> if a > 7: b = '>7' elif a == 7: b = '7' else: b = '<7' </pre> # hack `b = '>7' if a > 7 else '7' if a == 7 else '<7'`