Quick actions

cmd+k|ctrl+k

Navigation

Languages

Ternary Operator

Snippet info

Language

Python

Visibility

public

Author

raulciprian.tudor

Created

2026-01-03T20:08:46.836764Z

Updated

2026-01-03T20:12:27.462329Z

# used in certain situations to keep code more clean, they are also called conditional expressions

# condition_if_true if condition else condition_if_else

is_friend = False
can_message = "message allowed" if is_friend else "not allowed to message"
print(can_message)
INFO