
Python's Ternary IF Operator (Inline Condition) | Python Essentials Tutorials
498 views
3________
Python ternary if-operator (variable = statement 1 if condition else statement 2) in Python is a simple yet powerful tool to create one-line Python statements that perform any operation upon a given condition. Unlike the traditional if-else condition structure, the return of the ternary if-operator can be directly assigned to a variable. That's why this if-operator is used frequently in Python lambda functions directly on Python shell or in Python code. Since the variable is optional, the ternary if-operator can also be used on operations on data structures such as Python lists and dictionaries very efficiently.
Full Python course, visit: https://mechtutor.thinkific.com/cours...
コメント